Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Return non zero on errors/warnings #26

Closed
4lejandrito opened this issue Apr 9, 2018 · 3 comments
Closed

Return non zero on errors/warnings #26

4lejandrito opened this issue Apr 9, 2018 · 3 comments

Comments

@4lejandrito
Copy link
Member

Hi,

I am running gradle formatSource on a module with a package.json file containing:

"scripts": {
  "build": "cross-env NODE_ENV=production babel --source-maps -d classes/META-INF/resources src/main/resources/META-INF/resources && liferay-npm-bundler",
  "checkFormat": "npm run csf",
  "csf": "csf src/**/*.js",
  "format": "npm run csf -- -i"
}

I can see that it does run npm run csf -- -i but the build passes successfully and no warnings are printed to the console.

If I run it directly (without gradle) it does print warnings but returns 0.

Would it be possible to add a parameter so that a non zero value is returned when there are errors / warnings that must be fixed?

Thanks!

@natecavanaugh
Copy link
Contributor

Hi Alejandro,
Sorry for the delay, but I'll consider this, and try to see if there's a way to do it.

Here's the main issue/reasoning:

  1. Long term, I plan to split up the difference between what's an actual error vs. what's a warning, because sometimes, there are out and out errors (missing semicolon, script won't parse, etc), but then there are things that look fishy, but in that specific case, it's more just to remind you to take a look and ensure it's needed.
    So that might mean needing to eventually add 2 flags, basically something like --fail-all and --fail-errors.
  2. There are some cases (hopefully not too many), where there are some false positives on the errors, and if your particular code won't build because of them, I could see it being a problem. Granted, even most false positives, there's some sort of work around to trick the formatter into ignoring it, but it could become an issue.

However, having a way to signal to the executor of the script that it should report as a failure is an important thing, so I'll leave this one open and work on it.

Thanks Alejandro!

@4lejandrito
Copy link
Member Author

Thanks @natecavanaugh! I will keep an eye on this :)

@natecavanaugh
Copy link
Contributor

Hi Alejandro,
Rather than waiting until I split the reporting into errors and warnings, I added a new flag called --fail-on-errors, which if any of the files report an error, the exit code will be 1.

If you find any problems with it, please don't hesitate to let me know :)

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

No branches or pull requests

2 participants