diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 1399b57..4e73427 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/src/setup_build.jl b/src/setup_build.jl index f7df715..d85592b 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -9,31 +9,49 @@ 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_dir3")) + build_node(@get_scratch!("build_dir4")) end +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 + @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))) + end end + + npm_cache_dir = @get_scratch!("npm_cache") + + cmd = addenv(npm_cmd(), "NPM_CONFIG_CACHE" => npm_cache_dir) + + @info "huh" cmd + + cd(dir) do + run(`$(cmd) --version`) + run(`$(cmd) install --audit-level=none --no-fund --no-audit`) + end + + dir end - - cd(dir) do - run(`$npm --version`) - run(`$npm install`) - end - - 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.)"