Skip to content

Commit 750523b

Browse files
authored
chore(ci): make pre-commit hook instant (#702)
1 parent e93a31c commit 750523b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

scripts/ci/githubActions/setRunVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const COMMON_DEPENDENCIES = {
2727
'.github/workflows',
2828
'.github/.cache_version',
2929
],
30-
SCRIPTS_CHANGED: ['scripts', 'eslint', 'yarn.lock'],
30+
SCRIPTS_CHANGED: ['scripts', 'eslint', 'yarn.lock', '.eslintrc.js'],
3131
COMMON_SPECS_CHANGED: ['specs/common'],
3232
};
3333

scripts/ci/husky/pre-commit.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ async function preCommit() {
4141
const stagedFiles = (await run('git diff --name-only --cached')).split('\n');
4242

4343
const toUnstage = micromatch.match(stagedFiles, getPatterns());
44+
if (toUnstage.length === 0) {
45+
return;
46+
}
4447

45-
for (const file of toUnstage) {
48+
toUnstage.forEach((file) =>
4649
console.log(
4750
chalk.black.bgYellow('[INFO]'),
4851
`Generated file found, unstaging: ${file}`
49-
);
50-
51-
await run(`git restore --staged ${file}`);
52-
}
52+
)
53+
);
54+
await run(`git restore --staged ${toUnstage.join(' ')}`);
5355
}
5456

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

0 commit comments

Comments
 (0)