diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 55a311a..05c8cd9 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -11,6 +11,9 @@ on: paths-ignore: - "**.md" +env: + NPM_CONFIG_LOGLEVEL: verbose + jobs: test: runs-on: ${{ matrix.os }} diff --git a/Project.toml b/Project.toml index 1b430b4..6179afa 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "PlutoPDF" uuid = "6eb38059-8c05-41f7-8871-5e7e2697ace6" license = "MIT" authors = ["Fons van der Plas", "Connor Burns"] -version = "1.1.0" +version = "1.2.0" [deps] DefaultApplication = "3f0dd361-4fe0-5fc6-8523-80b14ec94d85" diff --git a/src/setup_build.jl b/src/setup_build.jl index 57ee1bf..38c01b0 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -9,34 +9,46 @@ const node_root_files = ( @path(joinpath(dirname(@__DIR__), "node", "package.json")), ) -const npm = !Sys.iswindows() ? NodeJS_20_jll.npm : let - new = "$(NodeJS_20_jll.npm).cmd" - isfile(new) ? new : NodeJS_20_jll.npm + +function npm_cmd() + npm = !Sys.iswindows() ? NodeJS_20_jll.npm : let + new = "$(NodeJS_20_jll.npm).cmd" + isfile(new) ? new : NodeJS_20_jll.npm + end + + # Add NodeJS PATH to the existing PATH environment variable + path_sep = Sys.iswindows() ? ';' : ':' + path_list = prepend!(split(get(ENV, "PATH", ""), path_sep), NodeJS_20_jll.PATH_list) + path = join(path_list, path_sep) + addenv(`$(npm)`, "PATH" => path) end function get_build_dir() build_node(@get_scratch!("build_dir4")) end -ci() = get(ENV, "CI", "neetjes") != "neetjes" +const node_build_lock = ReentrantLock() function build_node(dir) - @info "PlutoPDF: Running npm install in scratch space..." - - if dir !== dirname(node_root_files[1]) - for f in node_root_files - readwrite(f, joinpath(dir, basename(f))) + lock(node_build_lock) do + npm_cache_dir = @get_scratch!("npm_cache") + cmd = addenv(npm_cmd(), "NPM_CONFIG_CACHE" => npm_cache_dir) + + @info "PlutoPDF: Running npm install in scratch space..." npm_version=Text(read(`$(cmd) --version`, String)) + + if dir != dirname(node_root_files[1]) + for f in node_root_files + readwrite(f, joinpath(dir, basename(f))) + end end + + cd(dir) do + run(`$(cmd) install --audit-level=none --no-fund --no-audit`) + end + + @info "PlutoPDF: Finished npm install." + dir end - - cd(dir) do - run(`$npm --version`) - run(ci() ? `$npm install --verbose` : `$npm install`) - end - - @info "PlutoPDF: Finished npm install." - - dir end "Like `cp` except we create the file manually (to fix permission issues). (It's not plagiarism if you use this function to copy homework.)"