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

throws error if run as npm script #40

Closed
adekbadek opened this issue Sep 13, 2016 · 3 comments
Closed

throws error if run as npm script #40

adekbadek opened this issue Sep 13, 2016 · 3 comments

Comments

@adekbadek
Copy link

When I run $ jsinspect <path> directly from the command line, it works as expected. However when I run it as an npm script ($ npm run jsinspect)

"scripts": {
  "jsinspect": "jsinspect src/"
},

and matches are found, error is thrown:

 1 match found across 2 files

npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/aborowski/.nvm/versions/node/v6.3.1/bin/node" "/Users/aborowski/.nvm/versions/node/v6.3.1/bin/npm" "run" "jsinspect"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! test@1.0.0 jsinspect: `jsinspect src/`
npm ERR! Exit status 1
@danielstjules
Copy link
Owner

Yup! That's intended. From https://github.com/danielstjules/jsinspect#integration

It's simple to run jsinspect on your library source as part of a build process. It will exit with an error code of 0 when no matches are found, resulting in a passing step, and a positive error code corresponding to its failure. For example, with Travis CI, you could add the following entries to your .travis.yml:

Notice the "Exist status 1". That allows the error to be detected by CI like travis so you can have builds pass/fail based on the result. :)

@adekbadek
Copy link
Author

@danielstjules thanks for the quick response! What do you think about a --noerror flag, to make npm script use a bit more pleasant? I could try to PR if you're ok with the idea

@danielstjules
Copy link
Owner

@adekbadek Just ignore the exit code :)

"scripts": {
  "jsinspect": "jsinspect src/ || true"
},

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