Skip to content

Commit 3bf48b7

Browse files
committed
chore(ci): make pre-commit hook instant
1 parent 38c0ddc commit 3bf48b7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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)