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:
{
"scripts": {
"build": "wireit",
},
"wireit": {
"build": {
"command": "tsc"
}
}
}
and it's run with npm run build, yarn run build, etc. So Wireit needs npm_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 the npm_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.
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_eventto 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:
{ "scripts": { "build": "wireit", }, "wireit": { "build": { "command": "tsc" } } }and it's run with
npm run build,yarn run build, etc. So Wireit needsnpm_lifecycle_eventto 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
npmoverhead could be noticeable.Downstream issue: google/wireit#1094
What is the feature you are proposing to solve the problem?
node --runset thenpm_lifecycle_eventenvironment 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.