Skip to content

Commit

Permalink
Use nodejs path list (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Jan 30, 2025
1 parent d071dae commit cafbb7a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
48 changes: 30 additions & 18 deletions src/setup_build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.)"
Expand Down

2 comments on commit cafbb7a

@fonsp
Copy link
Member Author

@fonsp fonsp commented on cafbb7a Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/124007

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" cafbb7a74355510bda0defeb3aba7b7152f9ae82
git push origin v1.2.0

Please sign in to comment.