Skip to content

fix invocation of npm and npx #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/search/pagefind.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module PageFind
using NodeJS_22_jll: npx, npm
using NodeJS_22_jll: npx, npm, node
using HypertextLiteral: @htl

function inject_script!(custom_scripts, rootpath)
Expand Down Expand Up @@ -29,16 +29,22 @@ function render()
end

function build_search_index(root, docs, config, rootpath)
if !success(Cmd(`$(npx) pagefind -V`; dir = root))
@info "Installing pagefind into $root."
if !success(Cmd(`$(npm) install pagefind`; dir = root))
error("Could not install pagefind.")
# npx and npm are distributed as FileProducts,
Copy link
Contributor

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
Avoid writing lines with trailing whitespace.

To resolve this comment:

💡 Follow autofix suggestion

Suggested change
# npx and npm are distributed as FileProducts,
# npx and npm are distributed as FileProducts,
View step-by-step instructions
  1. Remove any spaces or tab characters at the end of the line containing # npx and npm are distributed as FileProducts,.
  2. Make sure to check for and remove trailing whitespace on other lines in the same file as well, to prevent similar issues.

Trailing whitespace can cause unnecessary diffs and may lead to style enforcement errors in the future.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in [Semgrep AppSec Platform](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542206) to ignore the finding created by no-whitespace-trailing.

You can view more details about [this finding](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542206) in the Semgrep AppSec Platform.

# so the JLL does not bundle environment information into them.
# To fix this, we wrap all uses of npx and npm inside `node() do ...`
# which will automatically adjust the necessary environment variables.
node() do
Copy link
Contributor

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
Avoid writing lines with trailing whitespace.

To resolve this comment:

💡 Follow autofix suggestion

Suggested change
node() do
node() do
View step-by-step instructions
  1. Delete any spaces or tabs after the code on the line node() do.
    The line should end immediately after the do, with no extra whitespace.
  2. Save the changes so that no lines in your code end with trailing whitespace.
💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in [Semgrep AppSec Platform](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542205) to ignore the finding created by no-whitespace-trailing.

You can view more details about [this finding](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542205) in the Semgrep AppSec Platform.

if !success(Cmd(`$(npx) pagefind -V`; dir = root))
@info "Installing pagefind into $root."
if !success(Cmd(`$(npm) install pagefind`; dir = root))
error("Could not install pagefind.")
end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
Avoid writing lines with trailing whitespace.

To resolve this comment:

✨ Commit Assistant Fix Suggestion
  1. Find and remove any spaces or tabs at the end of each line in your code. Pay special attention to lines only containing whitespace, as well as code and comment lines that could have trailing spaces.
  2. Ensure that blank lines contain no spaces or tabs—each should be an empty line with just a newline character.
  3. Save the file and check your editor settings; many editors have an option to trim trailing whitespace automatically—enable this to help prevent future issues.

Trailing whitespace can cause unnecessary diffs and may lead to problems with tools that are sensitive to whitespace.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in [Semgrep AppSec Platform](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542204) to ignore the finding created by no-whitespace-trailing.

You can view more details about [this finding](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542204) in the Semgrep AppSec Platform.

pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}"

Copy link
Contributor

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
Avoid writing lines with trailing whitespace.

To resolve this comment:

✨ Commit Assistant Fix Suggestion
  1. Remove any extra spaces or tabs at the end of each line in your code, particularly in blank lines and comments.
  2. Check all lines in the affected file for trailing whitespace and delete those trailing spaces, so blank lines are truly empty and other lines have no spaces or tabs after the final character.
  3. Save the file after removing all trailing whitespace.

Many editors support automatic removal of trailing whitespace (for example, in VSCode, you can enable "Trim Trailing Whitespace" in settings). Removing trailing whitespace helps prevent unnecessary diffs and keeps code clean.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in [Semgrep AppSec Platform](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542203) to ignore the finding created by no-whitespace-trailing.

You can view more details about [this finding](https://semgrep.dev/orgs/JuliaHub, Inc/findings/186542203) in the Semgrep AppSec Platform.

run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`)
end

pattern = "*/{$(join(config.index_versions, ","))}/**/*.{html}"

run(`$(npx) pagefind --site $(root) --glob $(pattern) --root-selector article`)
return nothing
end

Expand Down
Loading