Skip to content

Commit

Permalink
feat: add check when running in git hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pnodet committed Oct 4, 2024
1 parent 337bbb7 commit a899b1a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
/* eslint-disable no-constant-binary-expression */
import { isPackageExists } from 'local-pkg';

export const HAS_TYPESCRIPT = isPackageExists('typescript');
export const HAS_REACT = isPackageExists('react');
export const HAS_NEXTJS = isPackageExists('next');
export const HAS_TAILWINDCSS = isPackageExists('tailwindcss');

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

export const isInEditorEnv = (): boolean => {
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
);
};

0 comments on commit a899b1a

Please sign in to comment.