diff --git a/Project.toml b/Project.toml index c13e11d4..29fe5b31 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DocumenterVitepress" uuid = "4710194d-e776-4893-9690-8d956a29c365" authors = ["Lazaro Alonso ", "Anshul Singhvi "] -version = "0.0.18" +version = "0.0.19" [deps] ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" diff --git a/src/DocumenterVitepress.jl b/src/DocumenterVitepress.jl index db615822..a0b3f1c5 100644 --- a/src/DocumenterVitepress.jl +++ b/src/DocumenterVitepress.jl @@ -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")) diff --git a/src/writer.jl b/src/writer.jl index ae3d3999..2ae3615d 100644 --- a/src/writer.jl +++ b/src/writer.jl @@ -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)