Open thislooksfun opened 7 months ago
The issue is in the static completion
method for the run-script
command. It always operates on npm.localPrefix
which will be the root package.json for workspace.
Ideally that method could use the workspace directory if it was the pwd, or even parse the args so npm run -w workspace <tab>
would find the directory for workspace
.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When run from a workspace sub-folder, the
npm run
autocomplete only lists scripts from the workspace root package.json. This is a problem because those aren't the scripts thatnpm run
actually can execute in that context. Trying to run one of the autocompleted script names will fail with "npm ERR! Error: Missing script".Expected Behavior
It should list scripts from the nearest ancestor package.json, as that is what will actually be executed, not the ones from the root.
Steps To Reproduce
cd
to the workspace foldernpm run
and press TabEnvironment