Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use nodejs path list #19

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
paths-ignore:
- "**.md"

env:
NPM_CONFIG_LOGLEVEL: verbose

jobs:
test:
runs-on: ${{ matrix.os }}
Expand Down
50 changes: 34 additions & 16 deletions src/setup_build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
fonsp marked this conversation as resolved.
Show resolved Hide resolved
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.)"
Expand Down
Loading