language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

svelte-check: Custom exit error code if only warnings

Open vekunz opened this issue 2 years ago • 1 comments

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

vekunz avatar Jun 02 '23 11:06 vekunz

Alternatively, You can create a node script that:

  1. Spwan an child process with the stdio option set to 'inherit' for svelte-check
  2. listen to 'data' event of ChildProcess.stdio
  3. 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.

jasonlyu123 avatar Jun 06 '23 01:06 jasonlyu123