Skip to content

Commit

Permalink
fix: isInEditorEnv should be false when in git hooks, close #589
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 21, 2024
1 parent c62102b commit b60bfd3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,23 @@ export async function ensurePackages(packages: (string | undefined)[]): Promise<
}

export function isInEditorEnv(): boolean {
return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI)
if (process.env.CI)
return false
if (isInGitHooksOrLintStaged())
return false
return !!(false
|| process.env.VSCODE_PID
|| process.env.VSCODE_CWD
|| process.env.JETBRAINS_IDE
|| process.env.VIM
|| process.env.NVIM
)
}

export function isInGitHooksOrLintStaged(): boolean {
return !!(false
|| process.env.GIT_PARAMS
|| process.env.VSCODE_GIT_COMMAND
|| process.env.npm_lifecycle_script?.startsWith('lint-staged')
)
}

0 comments on commit b60bfd3

Please sign in to comment.