|
1 | 1 | module PageFind
|
2 |
| -using NodeJS_22_jll: npx, npm |
| 2 | +using NodeJS_22_jll: npx, npm, node |
3 | 3 | using HypertextLiteral: @htl
|
4 | 4 |
|
5 | 5 | function inject_script!(custom_scripts, rootpath)
|
@@ -29,20 +29,26 @@ function render()
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | 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 |
36 | 42 | end
|
37 |
| - end |
38 | 43 |
|
39 |
| - pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}" |
| 44 | + pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}" |
40 | 45 |
|
41 |
| - out_path = joinpath(root, "pagefind") |
42 |
| - mktempdir() do dir |
43 |
| - # pagefind doesn't look at symlinks, so we resolve them here: |
44 |
| - cp(root, dir; follow_symlinks = true, force = true) |
45 |
| - run(`$(npx) pagefind --site $(dir) --output-path $(out_path) --glob $(pattern) --root-selector article`) |
| 46 | + out_path = joinpath(root, "pagefind") |
| 47 | + mktempdir() do dir |
| 48 | + # pagefind doesn't look at symlinks, so we resolve them here: |
| 49 | + cp(root, dir; follow_symlinks = true, force = true) |
| 50 | + run(`$(npx) pagefind --site $(dir) --output-path $(out_path) --glob $(pattern) --root-selector article`) |
| 51 | + end |
46 | 52 | end
|
47 | 53 |
|
48 | 54 | return nothing
|
|
0 commit comments