src: traverse parent folders while running `--run`
This adds the most requested 2 features to node --run
:
- Traversing parent folders until
package.json
file is found. - Prepending
node_modules/.bin
for each subdirectory of the current folder toPATH
variable (specifically for monorepos)
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 test
cc @nodejs/cpp-reviewers