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

Use another exit code for internal error. #1361

Open
risu729 opened this issue Nov 14, 2023 · 1 comment
Open

Use another exit code for internal error. #1361

risu729 opened this issue Nov 14, 2023 · 1 comment

Comments

@risu729
Copy link

risu729 commented Nov 14, 2023

Description

I'm using lint-staged in my GitHub Actions and want to detect whether lint-staged has failed because of the failure of internal git diff or because of linters.

For example, git diff always throws an error if it is the first commit. (I can use the /dev/null hash to avoid it, but it is complicated and cannot handle other errors.)

I suggest using another exit code for internal errors, including git diff, like prettier.

I checked through the current behavior of lint-staged, and it always exits with 1, as defined here.

try {
const passed = await lintStaged(options)
process.exitCode = passed ? 0 : 1
} catch {
process.exitCode = 1
}

@therealgilles
Copy link

Can the caught error be displayed when it's an internal error?

try {
  const passed = await lintStaged(options)
  process.exitCode = passed ? 0 : 1
} catch (e) {
  throw new Error(e) // <-- ADD THIS
  process.exitCode = 1
}

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

No branches or pull requests

2 participants