language-tools
language-tools copied to clipboard
svelte-check: Custom exit error code if only warnings
Description
We want to run svelte-check directly in our CI pipeline as a job. We use GitLab CI for this. GitLab has a feature that a job can either fail or warn based on the exit code of the job. We already use this for example in our integration tests (fail-state if normal tests fail, and warn-state if "just" a11y tests fail). It would be great if we could use this feature with svelte-check also, since svelte-check already distinguishes between errors and warnings.
Proposed solution
Since GitLab decides the state based on exit codes, svelte-check needs to exit with another exit code (if --fail-on-warnings is set) if only warnings are present than if errors are present also (In GitLab CI we can freely define which exit code leads to warn-state).
Alternatives
If you don't want to change the default behavior for the --fail-on-warnings parameter, another option (which some other CLI tools use also) would be to add another parameter to define the exit code for warnings, like --warnings-exit-code <code> or so.
Additional Information, eg. Screenshots
No response
Alternatively, You can create a node script that:
- Spwan an child process with the
stdiooption set to'inherit'for svelte-check - listen to
'data'event ofChildProcess.stdio - if svelte-check finishes with only warnings, Exit with whatever exit code you like
Do you know if other build/type-check tools have this kind of flag? I am not sure if we want to add this since this can be done by the user side.