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
|
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: