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

npm run build and its friends do not fail early #8

Open
RA80533 opened this issue May 9, 2021 · 1 comment
Open

npm run build and its friends do not fail early #8

RA80533 opened this issue May 9, 2021 · 1 comment

Comments

@RA80533
Copy link

RA80533 commented May 9, 2021

"build": "rm -rf ./dist; mkdir ./dist; cp -r package.json README.md ./dist; tsc; webpack;",

Commands should be separated with the && operator. Currently, the commands execute sequentially but every return status up to that of the webpack invocation is swallowed.

npm run release also demonstrates the issue.

EDIT: I was mistaken with regards to why semicolons were used. In case it's not apparent, semicolons seem to be used for the exact purpose of circumventing a prior command failing. Specifically, a script may enter a directory, issue a command with a relative likeliness to fail in some way, and exit the directory regardless of the previous command's return status.

The scripts written with the semicolon pattern are still likely to cause issues if a failure return status is returned mid-script. For example, npm run publish, specifically, will always appear to succeed even if its invocation of npm publish has not. Workflow results from GitHub Actions would always imply the script ran correctly, etc.

While replacing each semicolon with a corresponding && will fix the problem of commands appearing as if they've succeeded when they haven't, it will break the last directory traversal of any scripts in which an error causes an early failure. A full solution would be to replace the directory traversal pattern used in the scripts with the conventional inclusion/exclusion file rules for building and package deployment, etc.

The short npm developer guide contains a bit of information on the subject.

@RA80533 RA80533 changed the title npm run build does not fail early npm run build and its friends do not fail early May 9, 2021
@petrvecera
Copy link
Contributor

Thanks for the report we will look into it 👍

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

No branches or pull requests

2 participants