-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
cli: implement node --run <script-in-package-json>
#52190
cli: implement node --run <script-in-package-json>
#52190
Conversation
Review requested:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
424a48c
to
dae84d3
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
dae84d3
to
0c7a248
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
I don't have a strong opinion on this, but I do share some concerns:
|
This comment was marked as resolved.
This comment was marked as resolved.
05d4b8a
to
0277f43
Compare
This comment was marked as resolved.
This comment was marked as resolved.
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
This comment was marked as outdated.
This comment was marked as outdated.
I'd love to learn how to add benchmarks by doing this, happy to pair with someone on this if anyone's interested 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the --run
updates everywhere, it LGTM!
Nice job!
Co-authored-by: Daniel Lemire <daniel@lemire.me>
0a38c95
to
2771947
Compare
Landed in 128c60d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
if (args.length > 0) { | ||
command += ' ' + escapeShell(args.map((arg) => arg.trim()).join(' ')); | ||
} | ||
execSync(command, { stdio: 'inherit', env, shell: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Have you considered using spawn instead of execSync, which has limitations in buffer size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was re-written in cpp 🙂
Lines 286 to 288 in b1c1faf
auto runner = | |
ProcessRunner(result, std::string(command_id), command, positional_args); | |
runner.Run(); |
Lines 216 to 222 in b1c1faf
void ProcessRunner::Run() { | |
if (int r = uv_spawn(loop_, &process_, &options_)) { | |
fprintf(stderr, "Error: %s\n", uv_strerror(r)); | |
} | |
uv_run(loop_, UV_RUN_DEFAULT); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @atlowChemi for clarifying!
@marco-ippolito what's the reason for making this "baking for lts"? |
Being a big new feature, I think we should have waited more than two weeks before landing it in LTS. I'm ok with landing this in v20.15.0 |
Co-authored-by: Daniel Lemire
The purpose of this pull-request to offer a fast alternative to
npm run xxx
. With this pull-request, node supportsnode run test
which executestest
command insidepackage.json
scripts.Locally the overhead that
node run <cmd>
adds to runningcmd
is ~200ms less thannpm run <cmd>
TODO
node_modules/.bin
to PATH.execSync
Benchmark