Skip to content

Commit

Permalink
Wrap all invocations of npm in node to set the PATH appropriate…
Browse files Browse the repository at this point in the history
…ly (#123)

* Fix #122

* Bump version
  • Loading branch information
asinghvi17 authored May 6, 2024
1 parent 79acc70 commit 70aa87d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DocumenterVitepress"
uuid = "4710194d-e776-4893-9690-8d956a29c365"
authors = ["Lazaro Alonso <[email protected]>", "Anshul Singhvi <[email protected]>"]
version = "0.0.18"
version = "0.0.19"

[deps]
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
Expand Down
2 changes: 1 addition & 1 deletion src/DocumenterVitepress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module DocumenterVitepress
using Documenter: Documenter, Selectors

using DocStringExtensions
using NodeJS_20_jll: npm
using NodeJS_20_jll: node, npm

const ASSETS = normpath(joinpath(@__DIR__, "..", "assets"))

Expand Down
18 changes: 12 additions & 6 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,20 @@ function render(doc::Documenter.Document, settings::MarkdownVitepress=MarkdownVi
end

cd(dirname(builddir)) do
if settings.install_npm || should_remove_package_json
if !isfile(joinpath(dirname(builddir), "package.json"))
cp(joinpath(dirname(@__DIR__), "template", "package.json"), joinpath(dirname(builddir), "package.json"))
should_remove_package_json = true
# NodeJS_20_jll treats `npm` as a `FileProduct`, meaning that it has no associated environment variable
# when interpolating the `npm` command.
# However, `node() do ...` actually uses `withenv` internally, so we can wrap all invocations of `npm` in
# a `node()` block to ensure that the `npm` from the JLL finds the `node` from the JLL.
node(; adjust_PATH = true, adjust_LIBPATH = true) do _
if settings.install_npm || should_remove_package_json
if !isfile(joinpath(dirname(builddir), "package.json"))
cp(joinpath(dirname(@__DIR__), "template", "package.json"), joinpath(dirname(builddir), "package.json"))
should_remove_package_json = true
end
run(`$(npm) install`)
end
run(`$(npm) install`)
run(`$(npm) run docs:build`)
end
run(`$(npm) run docs:build`)
end
catch e
rethrow(e)
Expand Down

2 comments on commit 70aa87d

@asinghvi17
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@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/106244

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 v0.0.19 -m "<description of version>" 70aa87dec4c25b5ef0119fcc38ad0512f8728554
git push origin v0.0.19

Please sign in to comment.