| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
I thought this one was hard/next to impossible to do safely for Windows because of the short limit of the path variable there? There was a comment to this effect on an earlier thread. |
Sorry, something went wrong.
I found the following solution online, might fix it:
|
Sorry, something went wrong.
|
Since the path part is potentially problematic, should it be a separate PR? The traversing up the tree part is straightforward and could just land I'd think. |
Sorry, something went wrong.
|
Also, checking if the node_modules/.bin directory for each ancestor actually exists before adding it to PATH could possibly alleviate the issue. |
Sorry, something went wrong.
This would reduce the performance by a significant margin, and isn't in par with npm (but that's not a supportive argument just a fact) |
Sorry, something went wrong.
It's a very minor cost compared to the other work that's being done, and skipping these checks would really just offload the work to the subprocesses being run (such as the shell), which would have to look through all of these nonexistent paths for binaries to execute, so it doesn't prevent the performance cost. |
Sorry, something went wrong.
I think you mean each parent directory, not each sub directory? I haven't checked the implementation, but you can probably get away with only adding node_modules/.bin to the path for every parent directory you find containing a package.json file, and can also further check if {dir}/node_modules/.bin is a directory. It adds some stats, but it'll help keep the PATH env within limits, and if you don't do those stats, then the OS will end up doing them anyway when it goes to look up executables. (This is close to what npm does.) Also, the node_modules/.bin should be pre-pended to the PATH env, not appended. Eg, if I have eslint installed globally, and a different version in the current project, I want the one in the closest containing project that has it, not the one at /usr/local/bin/eslint. |
Sorry, something went wrong.
|
@isaacs Thanks for the comment!
Yes, I've updated the CLI to use ancestor keyword.
Why do you think checking package_json is good? I'm currently checking if node_modules/.bin is a directory.
Yes, I'm pre-pending although I'm not sure how did you come to this conclusion? If it's my choice of words in the docs, can you point me to the correct place to fix it? |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Commit Queue failed- Loading data for nodejs/node/pull/53154 ✔ Done loading data for nodejs/node/pull/53154 ----------------------------------- PR info ------------------------------------ Title src: traverse parent folders while running `--run` (#53154) Author Yagiz Nizipli (@anonrig) Branch anonrig:traverse-until-root -> nodejs:main Labels c++, semver-minor, needs-ci Commits 1 - src: traverse parent folders while running `--run` Committers 1 - Yagiz Nizipli PR-URL: https://github.com/nodejs/node/pull/53154 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Daniel Lemire ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/53154 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Daniel Lemire -------------------------------------------------------------------------------- ℹ This PR was created on Sun, 26 May 2024 00:20:07 GMT ✔ Approvals: 2 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/53154#pullrequestreview-2086340450 ✔ - Daniel Lemire (@lemire): https://github.com/nodejs/node/pull/53154#pullrequestreview-2088970099 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2024-05-31T11:06:06Z: https://ci.nodejs.org/job/node-test-pull-request/59561/ - Querying data for job/node-test-pull-request/59561/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/9318146805 |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
PR-URL: #53154 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: James M Snell <jasnell@gmail.com>
Notable changes: buffer: * (SEMVER-MINOR) add .bytes() method to Blob (Matthew Aitken) #53221 cli: * (SEMVER-MINOR) add `NODE_RUN_PACKAGE_JSON_PATH` env (Yagiz Nizipli) #53058 * (SEMVER-MINOR) add `NODE_RUN_SCRIPT_NAME` env to `node --run` (Yagiz Nizipli) #53032 doc: * (SEMVER-MINOR) add context.assert docs (Colin Ihrig) #53169 * (SEMVER-MINOR) improve explanation about built-in modules (Joyee Cheung) #52762 * add StefanStojanovic to collaborators (StefanStojanovic) #53118 * add Marco Ippolito to TSC (Rafael Gonzaga) #53008 fs: * mark recursive cp methods as stable (Théo LUDWIG) #53127 lib: * (SEMVER-MINOR) add EventSource Client (Aras Abbasi) #51575 * (SEMVER-MINOR) replace MessageEvent with undici's (Matthew Aitken) #52370 module: * (SEMVER-MINOR) print amount of load time of a cjs module (Vinicius Lourenço) #52213 net: * (SEMVER-MINOR) add new net.server.listen tracing channel (Paolo Insogna) #53136 process: * (SEMVER-MINOR) add process.getBuiltinModule(id) (Joyee Cheung) #52762 src: * (SEMVER-MINOR) traverse parent folders while running `--run` (Yagiz Nizipli) #53154 src,permission: * (SEMVER-MINOR) --allow-wasi & prevent WASI exec (Rafael Gonzaga) #53124 test_runner: * (SEMVER-MINOR) add snapshot testing (Colin Ihrig) #53169 * (SEMVER-MINOR) add context.fullName (Colin Ihrig) #53169 * (SEMVER-MINOR) support module mocking (Colin Ihrig) #52848 PR-URL: #53379
Notable changes: buffer: * (SEMVER-MINOR) add .bytes() method to Blob (Matthew Aitken) #53221 cli: * (SEMVER-MINOR) add `NODE_RUN_PACKAGE_JSON_PATH` env (Yagiz Nizipli) #53058 * (SEMVER-MINOR) add `NODE_RUN_SCRIPT_NAME` env to `node --run` (Yagiz Nizipli) #53032 doc: * (SEMVER-MINOR) add context.assert docs (Colin Ihrig) #53169 * (SEMVER-MINOR) improve explanation about built-in modules (Joyee Cheung) #52762 * add StefanStojanovic to collaborators (StefanStojanovic) #53118 * add Marco Ippolito to TSC (Rafael Gonzaga) #53008 fs: * mark recursive cp methods as stable (Théo LUDWIG) #53127 lib: * (SEMVER-MINOR) add EventSource Client (Aras Abbasi) #51575 * (SEMVER-MINOR) replace MessageEvent with undici's (Matthew Aitken) #52370 module: * (SEMVER-MINOR) print amount of load time of a cjs module (Vinicius Lourenço) #52213 net: * (SEMVER-MINOR) add new net.server.listen tracing channel (Paolo Insogna) #53136 process: * (SEMVER-MINOR) add process.getBuiltinModule(id) (Joyee Cheung) #52762 src: * (SEMVER-MINOR) traverse parent folders while running `--run` (Yagiz Nizipli) #53154 src,permission: * (SEMVER-MINOR) --allow-wasi & prevent WASI exec (Rafael Gonzaga) #53124 test_runner: * (SEMVER-MINOR) add snapshot testing (Colin Ihrig) #53169 * (SEMVER-MINOR) add context.fullName (Colin Ihrig) #53169 * (SEMVER-MINOR) support module mocking (Colin Ihrig) #52848 PR-URL: #53379
PR-URL: nodejs#53154 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: James M Snell <jasnell@gmail.com>
Notable changes: buffer: * (SEMVER-MINOR) add .bytes() method to Blob (Matthew Aitken) nodejs#53221 cli: * (SEMVER-MINOR) add `NODE_RUN_PACKAGE_JSON_PATH` env (Yagiz Nizipli) nodejs#53058 * (SEMVER-MINOR) add `NODE_RUN_SCRIPT_NAME` env to `node --run` (Yagiz Nizipli) nodejs#53032 doc: * (SEMVER-MINOR) add context.assert docs (Colin Ihrig) nodejs#53169 * (SEMVER-MINOR) improve explanation about built-in modules (Joyee Cheung) nodejs#52762 * add StefanStojanovic to collaborators (StefanStojanovic) nodejs#53118 * add Marco Ippolito to TSC (Rafael Gonzaga) nodejs#53008 fs: * mark recursive cp methods as stable (Théo LUDWIG) nodejs#53127 lib: * (SEMVER-MINOR) add EventSource Client (Aras Abbasi) nodejs#51575 * (SEMVER-MINOR) replace MessageEvent with undici's (Matthew Aitken) nodejs#52370 module: * (SEMVER-MINOR) print amount of load time of a cjs module (Vinicius Lourenço) nodejs#52213 net: * (SEMVER-MINOR) add new net.server.listen tracing channel (Paolo Insogna) nodejs#53136 process: * (SEMVER-MINOR) add process.getBuiltinModule(id) (Joyee Cheung) nodejs#52762 src: * (SEMVER-MINOR) traverse parent folders while running `--run` (Yagiz Nizipli) nodejs#53154 src,permission: * (SEMVER-MINOR) --allow-wasi & prevent WASI exec (Rafael Gonzaga) nodejs#53124 test_runner: * (SEMVER-MINOR) add snapshot testing (Colin Ihrig) nodejs#53169 * (SEMVER-MINOR) add context.fullName (Colin Ihrig) nodejs#53169 * (SEMVER-MINOR) support module mocking (Colin Ihrig) nodejs#52848 PR-URL: nodejs#53379
| Back | FazBrowse Home | New Git URL |
This adds the most requested 2 features to node --run:
I've also updated the documentation. I think we are in good hands, and getting ready to make the runner stable.
With the current changes and the overhead of checking if it's a directory for each node_modules/.bin inside each ancestor folder, here's the updated benchmark results:
❯ hyperfine '../node/out/Release/node --run test' 'npm run test' -i -w 10 Benchmark 1: ../node/out/Release/node --run test Time (mean ± σ): 22.7 ms ± 1.2 ms [User: 17.0 ms, System: 2.7 ms] Range (min … max): 20.9 ms … 25.8 ms 118 runs Benchmark 2: npm run test Time (mean ± σ): 106.0 ms ± 4.0 ms [User: 82.5 ms, System: 14.1 ms] Range (min … max): 101.3 ms … 116.1 ms 28 runs Summary ../node/out/Release/node --run test ran 4.67 ± 0.31 times faster than npm run testcc @nodejs/cpp-reviewers