Skip to content
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

[BUG] npm run <script name> --if-present silently ignores missing scripts in subcommands #1215

Closed
papandreou opened this issue Apr 27, 2020 · 2 comments
Labels
Bug thing that needs fixing

Comments

@papandreou
Copy link

What / Why

The --if-present switch that npm run supports also cascades into other npm run commands executed by the script at all levels. It makes the --if-present switch a bit of a footgun, so I hope that's a bug :)

Background: I spent some time figuring out why a missing script referenced by an npm run ... inside another npm script didn't cause my Heroku deploy to fail. It turns out that it's because they use the --if-present flag when executing the top-level build script.

How

Steps to Reproduce

The problem can be illustrated with a simple package.json:

{
  "scripts": {
    "foo": "npm run notfound"
  }
}

To reproduce:

npm run --if-present foo

Expected Behavior

I expected it to fail with missing script: notfound, but it exits with 0 and no error message.

I would expect npm run --if-present <script name> to only apply its "silently ignore missing script" behavior wrt. the exact script I tell it to run. I don't want the behavior to cascade into other npm run ... commands that might be found in the script itself. If I wanted that, I would pass --if-present there explicitly also.

Who

  • n/a

References

  • n/a
@darcyclarke darcyclarke added the Bug thing that needs fixing label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is reproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

@papandreou
Copy link
Author

Re-filed as #3352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants