Skip to content

Commit

Permalink
chore(ci): make pre-commit hook instant (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Jun 16, 2022
1 parent e93a31c commit 750523b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/ci/githubActions/setRunVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const COMMON_DEPENDENCIES = {
'.github/workflows',
'.github/.cache_version',
],
SCRIPTS_CHANGED: ['scripts', 'eslint', 'yarn.lock'],
SCRIPTS_CHANGED: ['scripts', 'eslint', 'yarn.lock', '.eslintrc.js'],
COMMON_SPECS_CHANGED: ['specs/common'],
};

Expand Down
12 changes: 7 additions & 5 deletions scripts/ci/husky/pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ async function preCommit() {
const stagedFiles = (await run('git diff --name-only --cached')).split('\n');

const toUnstage = micromatch.match(stagedFiles, getPatterns());
if (toUnstage.length === 0) {
return;
}

for (const file of toUnstage) {
toUnstage.forEach((file) =>
console.log(
chalk.black.bgYellow('[INFO]'),
`Generated file found, unstaging: ${file}`
);

await run(`git restore --staged ${file}`);
}
)
);
await run(`git restore --staged ${toUnstage.join(' ')}`);
}

if (require.main === module && !process.env.CI) {
Expand Down

0 comments on commit 750523b

Please sign in to comment.