Skip to content

Commit 0d81c1e

Browse files
authored
Merge pull request #101 from JuliaComputing/asinghvi17-patch-2
fix invocation of npm and npx
2 parents 1c9d75f + 8477b4e commit 0d81c1e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/search/pagefind.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module PageFind
2-
using NodeJS_22_jll: npx, npm
2+
using NodeJS_22_jll: npx, npm, node
33
using HypertextLiteral: @htl
44

55
function inject_script!(custom_scripts, rootpath)
@@ -29,16 +29,22 @@ function render()
2929
end
3030

3131
function build_search_index(root, docs, config, rootpath)
32-
if !success(Cmd(`$(npx) pagefind -V`; dir = root))
33-
@info "Installing pagefind into $root."
34-
if !success(Cmd(`$(npm) install pagefind`; dir = root))
35-
error("Could not install pagefind.")
32+
# npx and npm are distributed as FileProducts,
33+
# so the JLL does not bundle environment information into them.
34+
# To fix this, we wrap all uses of npx and npm inside `node() do ...`
35+
# which will automatically adjust the necessary environment variables.
36+
node() do
37+
if !success(Cmd(`$(npx) pagefind -V`; dir = root))
38+
@info "Installing pagefind into $root."
39+
if !success(Cmd(`$(npm) install pagefind`; dir = root))
40+
error("Could not install pagefind.")
41+
end
3642
end
43+
44+
pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}"
45+
46+
run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`)
3747
end
38-
39-
pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}"
40-
41-
run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`)
4248
return nothing
4349
end
4450

0 commit comments

Comments
 (0)