Skip to content

Commit

Permalink
Include nested modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Feb 8, 2025
1 parent 31fea80 commit 4221173
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tour.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ fn make_prelude_available() -> snag.Result(Nil) {

fn make_stdlib_available() -> snag.Result(Nil) {
use files <- result.try(
simplifile.read_directory(stdlib_sources)
simplifile.get_files(stdlib_sources)
|> file_error("Failed to read stdlib directory"),
)

Expand All @@ -410,6 +410,7 @@ fn make_stdlib_available() -> snag.Result(Nil) {
|> list.filter(fn(file) { string.ends_with(file, ".gleam") })
|> list.filter(fn(file) { !list.contains(skipped_stdlib_modules, file) })
|> list.map(string.replace(_, ".gleam", ""))
|> list.map(string.replace(_, stdlib_sources <> "/", ""))

use _ <- result.try(
generate_stdlib_bundle(modules)
Expand Down Expand Up @@ -453,15 +454,16 @@ fn copy_compiled_stdlib(modules: List(String)) -> snag.Result(Nil) {
use <- require(is_directory, "Project must have been compiled for JavaScript")

let dest = public_precompiled <> "/gleam"
use _ <- result.try(
simplifile.create_directory_all(dest)
|> file_error("Failed to make " <> dest),
)

use _ <- result.try(
list.try_each(modules, fn(name) {
let from = stdlib_compiled <> "/" <> name <> ".mjs"
let to = dest <> "/" <> name <> ".mjs"
let parent = filepath.directory_name(to)
use _ <- result.try(
simplifile.create_directory_all(parent)
|> file_error("Failed to make " <> parent),
)
simplifile.copy_file(from, to)
|> file_error("Failed to copy stdlib module " <> from)
}),
Expand Down

0 comments on commit 4221173

Please sign in to comment.