Skip to content

Add -x / --node-run flag to bypass the package manager#225

Merged
bcomnes merged 5 commits into
masterfrom
feature/node-run
May 18, 2026
Merged

Add -x / --node-run flag to bypass the package manager#225
bcomnes merged 5 commits into
masterfrom
feature/node-run

Conversation

@bcomnes

@bcomnes bcomnes commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds opt-in support for running scripts via node --run instead of npm/pnpm/yarn. The per-script startup cost of the package manager CLI adds up fast with run-p — this flag lets you skip it entirely.

  • New -x / --node-run flag on all three commands (run-s, run-p, npm-run-all)
  • Project-wide opt-in via package.json: "npm-run-all2": { "nodeRun": true }
  • Short flags can be combined as usual (e.g. -lx)

Intentional limitations (inherited from node --run)

  • No pre/post lifecycle hooks
  • No npm_* environment variable injection (NODE_RUN_SCRIPT_NAME and NODE_RUN_PACKAGE_JSON_PATH are set instead)
  • node_modules/.bin is still added to PATH (traverses up to root)

Because of these limitations the flag is strictly opt-in and never the default.

Changes

File What changed
bin/common/parse-cli-args.js Added nodeRun field, -x/--node-run cases, extended CONCAT_OPTIONS regex
lib/run-task.js New execution branch: skips package manager detection, spawns node --run <script> [-- args]
lib/index.js Threads nodeRun option; reads package.json config opt-in (requires true boolean)
bin/run-{s,p}/main.js, bin/npm-run-all/main.js Pass nodeRun through to runAll()
docs/run-s.md, docs/run-p.md, docs/npm-run-all.md Document the new flag

Closes #155

…ager

Adds opt-in support for running scripts via `node --run` rather than
npm/pnpm/yarn. This avoids the per-script startup overhead of the
package manager CLI, which is especially noticeable with run-p.

Supports a project-wide opt-in via package.json:
  "npm-run-all2": { "nodeRun": true }

Intentional limitations inherited from node --run:
- No pre/post lifecycle hooks
- No npm_* environment variable injection
- No automatic PATH injection for local binaries

Closes #155
Copilot AI review requested due to automatic review settings May 17, 2026 22:38
Corrects the documented limitations. node --run does prepend
node_modules/.bin directories to PATH (traversing up to root),
so that bullet was wrong. The actual omissions are only pre/post
lifecycle hooks and npm_* env vars. Also note the NODE_RUN_SCRIPT_NAME
and NODE_RUN_PACKAGE_JSON_PATH env vars that node --run does set.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an opt-in -x/--node-run mode to execute scripts via node --run (bypassing npm/pnpm/yarn CLI overhead), with optional project-wide enablement via package.json config.

Changes:

  • Add -x/--node-run CLI flag parsing and support for combined short flags.
  • Implement a node --run execution path in task spawning, and thread the option through command entrypoints.
  • Document the new flag across run-s, run-p, and npm-run-all.

Reviewed changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/run-task.js Adds a node --run execution branch and routes spawning through common variables.
lib/index.js Threads nodeRun option and adds package.json-based global opt-in.
bin/common/parse-cli-args.js Parses -x/--node-run and allows x in concatenated short flags.
bin/run-s/main.js Passes nodeRun through to the library entrypoint.
bin/run-p/main.js Passes nodeRun through to the library entrypoint.
bin/npm-run-all/main.js Passes nodeRun through to the library entrypoint for each group.
docs/run-s.md Documents -x/--node-run behavior and config opt-in.
docs/run-p.md Documents -x/--node-run behavior and config opt-in.
docs/npm-run-all.md Documents -x/--node-run behavior and config opt-in.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/run-task.js
Comment thread lib/index.js Outdated
Comment thread docs/run-s.md
bcomnes added 2 commits May 17, 2026 15:46
- run-task.js: use first -- as the separator rather than filtering all
  -- tokens, so scripts that receive -- as an argument are not broken
- lib/index.js: require pkgConfig.nodeRun === true instead of any
  truthy value, so 'nodeRun: "false"' does not accidentally enable it
Extracts the npm-run-all2 package.json config reading into a
dedicated readPackageConfig() function with a PackageJsonConfig
typedef, making it easy to add new config options in the future.
Covers sequential, parallel, and lifecycle hook suppression for the
--node-run / -x flag via Node API, run-s, run-p, and npm-run-all.
Adds pre/post lifecycle scripts to test-workspace to verify they are
skipped when node --run is used.
@bcomnes

bcomnes commented May 18, 2026

Copy link
Copy Markdown
Owner Author

cc @jdalton @nolanlawson

@bcomnes bcomnes merged commit 992c0cf into master May 18, 2026
15 checks passed
@bcomnes bcomnes deleted the feature/node-run branch May 18, 2026 19:02
AnnAngela added a commit to MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes that referenced this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leverage Node 22.3.0's node --run for run-s when possible.

2 participants