From a5e51596d1cb61c4c1acad99e05a733b9ebf7e7b Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Sat, 10 Aug 2024 17:16:19 +0200 Subject: [PATCH 1/5] Use nodejs path list --- src/setup_build.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/setup_build.jl b/src/setup_build.jl index f7df715..196b0ad 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -14,6 +14,14 @@ const npm = !Sys.iswindows() ? NodeJS_20_jll.npm : let isfile(new) ? new : NodeJS_20_jll.npm end +const npm_cmd = let + # 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")) end @@ -29,8 +37,8 @@ function build_node(dir) end cd(dir) do - run(`$npm --version`) - run(`$npm install`) + run(`$npm_cmd --version`) + run(`$npm_cmd install`) end dir From 43921b1472d23be3978002a137fdd67a172d47ea Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Sat, 10 Aug 2024 17:34:19 +0200 Subject: [PATCH 2/5] move into function --- src/setup_build.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/setup_build.jl b/src/setup_build.jl index 196b0ad..8b4eca4 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -9,12 +9,13 @@ 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 -end -const npm_cmd = let +function npm_cmd() + const 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) @@ -37,8 +38,8 @@ function build_node(dir) end cd(dir) do - run(`$npm_cmd --version`) - run(`$npm_cmd install`) + run(`$(npm_cmd()) --version`) + run(`$(npm_cmd()) install`) end dir From a557373783ce47dd228b86b2fbc010ddef17cb23 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Sat, 10 Aug 2024 17:36:05 +0200 Subject: [PATCH 3/5] oops --- src/setup_build.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup_build.jl b/src/setup_build.jl index 8b4eca4..ef72e2d 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -11,7 +11,7 @@ const node_root_files = ( function npm_cmd() - const npm = !Sys.iswindows() ? NodeJS_20_jll.npm : let + npm = !Sys.iswindows() ? NodeJS_20_jll.npm : let new = "$(NodeJS_20_jll.npm).cmd" isfile(new) ? new : NodeJS_20_jll.npm end From aba35120cd317b72618aed2504f05fcc737d98e9 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Sat, 10 Aug 2024 20:03:08 +0200 Subject: [PATCH 4/5] Update setup_build.jl --- src/setup_build.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup_build.jl b/src/setup_build.jl index ef72e2d..9cd5cdb 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -39,7 +39,7 @@ function build_node(dir) cd(dir) do run(`$(npm_cmd()) --version`) - run(`$(npm_cmd()) install`) + run(`$(npm_cmd()) install --audit-level=none --no-fund --no-audit`) end dir From 56116ddc06064531f292c372626c2188d31cc345 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 14 Aug 2024 23:02:11 +0200 Subject: [PATCH 5/5] asdf --- .github/workflows/Test.yml | 3 +++ src/setup_build.jl | 35 ++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) 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 9cd5cdb..d85592b 100644 --- a/src/setup_build.jl +++ b/src/setup_build.jl @@ -24,25 +24,34 @@ function npm_cmd() 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_cmd()) --version`) - run(`$(npm_cmd()) install --audit-level=none --no-fund --no-audit`) - 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.)"