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 (LuxDL#123)

* Fix LuxDL#122

* Bump version
  • Loading branch information
asinghvi17 authored and thofma committed May 19, 2024
1 parent 444f98f commit c6083b3
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

0 comments on commit c6083b3

Please sign in to comment.