@@ -9,34 +9,46 @@ const node_root_files = (
9
9
@path (joinpath (dirname (@__DIR__ ), " node" , " package.json" )),
10
10
)
11
11
12
- const npm = ! Sys. iswindows () ? NodeJS_20_jll. npm : let
13
- new = " $(NodeJS_20_jll. npm) .cmd"
14
- isfile (new) ? new : NodeJS_20_jll. npm
12
+
13
+ function npm_cmd ()
14
+ npm = ! Sys. iswindows () ? NodeJS_20_jll. npm : let
15
+ new = " $(NodeJS_20_jll. npm) .cmd"
16
+ isfile (new) ? new : NodeJS_20_jll. npm
17
+ end
18
+
19
+ # Add NodeJS PATH to the existing PATH environment variable
20
+ path_sep = Sys. iswindows () ? ' ;' : ' :'
21
+ path_list = prepend! (split (get (ENV , " PATH" , " " ), path_sep), NodeJS_20_jll. PATH_list)
22
+ path = join (path_list, path_sep)
23
+ addenv (` $(npm) ` , " PATH" => path)
15
24
end
16
25
17
26
function get_build_dir ()
18
27
build_node (@get_scratch! (" build_dir4" ))
19
28
end
20
29
21
- ci () = get ( ENV , " CI " , " neetjes " ) != " neetjes "
30
+ const node_build_lock = ReentrantLock ()
22
31
23
32
function build_node (dir)
24
- @info " PlutoPDF: Running npm install in scratch space..."
25
-
26
- if dir != = dirname (node_root_files[1 ])
27
- for f in node_root_files
28
- readwrite (f, joinpath (dir, basename (f)))
33
+ lock (node_build_lock) do
34
+ npm_cache_dir = @get_scratch! (" npm_cache" )
35
+ cmd = addenv (npm_cmd (), " NPM_CONFIG_CACHE" => npm_cache_dir)
36
+
37
+ @info " PlutoPDF: Running npm install in scratch space..." npm_version= Text (read (` $(cmd) --version` , String))
38
+
39
+ if dir != dirname (node_root_files[1 ])
40
+ for f in node_root_files
41
+ readwrite (f, joinpath (dir, basename (f)))
42
+ end
29
43
end
44
+
45
+ cd (dir) do
46
+ run (` $(cmd) install --audit-level=none --no-fund --no-audit` )
47
+ end
48
+
49
+ @info " PlutoPDF: Finished npm install."
50
+ dir
30
51
end
31
-
32
- cd (dir) do
33
- run (` $npm --version` )
34
- run (ci () ? ` $npm install --verbose` : ` $npm install` )
35
- end
36
-
37
- @info " PlutoPDF: Finished npm install."
38
-
39
- dir
40
52
end
41
53
42
54
" Like `cp` except we create the file manually (to fix permission issues). (It's not plagiarism if you use this function to copy homework.)"
0 commit comments