-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Task runner (node --run) should set lifecycle_event environment variable #52673
Comments
node task runner is not a replacement for npm. Please take a look at the intentional limitations part in the documentation. |
This issue isn't asking for a replacement to npm, but a way to know which script was run so that delegated task runners can work. |
@justinfagnani The limitations include any npm or other package managers specific environment variables. Your request is to add the npm_lifecycle_event environment variable right? We can introduce "lifecycle_event" environment variable but this won't solve your issue. |
A |
Makes sense. Looks like a good feature. I've reopened it and will work on it after #52609 lands. |
Thank you @anonrig! Looking at the Wireit source code, it looks like it would need an equivalent to It also reads additional args, in npm via another env variable, but it might work with the additional args support you've already added (cc @aomarks). I realize there would be an understandable resistance to adding too many environment variables. |
Cool! Wireit maintainer here. I'm excited for What wireit needs to know
Examplenpm, pnpm, and yarn all provide this information one way or another. It varies across package managers and across their versions. Here's an example of how it works for npm: npm run myscript --watch -- arg1 arg2 This means "run myscript, with wireit's watch mode enabled, and pass
The relevant code is at https://github.com/google/wireit/blob/main/src/cli-options.ts SuggestionsMy thoughts about how this all affects
|
PR-URL: #53032 Refs: #52673 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
@aomarks I've opened one more pull-request to add
Unfortunately, I don't think we should add a
I didn't quite understand the |
Awesome!
👍
Yes, exactly. |
PR-URL: #53032 Refs: #52673 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: #53058 Refs: #52673 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
PR-URL: #53058 Refs: #52673 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
PR-URL: nodejs#53032 Refs: nodejs#52673 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#53058 Refs: nodejs#52673 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
PR-URL: nodejs#53032 Refs: nodejs#52673 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#53058 Refs: nodejs#52673 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
Adds support for the new node --run feature which is available starting in Node 22 (basically npm run but faster, see https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts and https://www.yagiz.co/developing-fast-builtin-task-runner/). Note that node --run is stricter than the other runners when it comes to distinguishing between arguments for the runner vs the script, so an additional -- is needed to set wireit flags and script flags (explained in the README). Thank you very much to @anonrig for adding the environment variables this required (nodejs/node#53032, nodejs/node#53058) and @justinfagnani for filing the issue (nodejs/node#52673)! There is a problem with recursive invocations on Windows that I believe is a Node bug but need to double-check, tracking at #1168. Fixes #1094
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-stale
|
What is the problem this feature will solve?
Some npm scripts delegate to another task runner (like Wireit) and require the environment variable
npm_lifecycle_event
to be set in order to tell which script to run. Yarn and pnpm both set this variable.The way a Wireit package.json is configured is like this:
and it's run with
npm run build
,yarn run build
, etc. So Wireit needsnpm_lifecycle_event
to find the script to run.Supporting task runner like Wireit would be great because Wireit caches script results, so some invocations don't perform any work after checking the cache and the
npm
overhead could be noticeable.Downstream issue: google/wireit#1094
What is the feature you are proposing to solve the problem?
node --run
set thenpm_lifecycle_event
environment variable to the current script.What alternatives have you considered?
Node could set a different variable and task runners like Wireit could detect that also.
The text was updated successfully, but these errors were encountered: