Skip to content

Commit eb4fe34

Browse files
authored
Fix prettier precommit script to not error if there are only deleted files (#2641)
1 parent b40d71e commit eb4fe34

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/gitHooks/prettier.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ async function doPrettierCommit() {
6363
console.error(e);
6464
return process.exit(1);
6565
}
66-
const diff = await git.diff(['--name-only', 'origin/master...HEAD']);
66+
const diff = await git.diff([
67+
'--name-only',
68+
'origin/master...HEAD',
69+
'--diff-filter',
70+
'd'
71+
]);
6772
// Only run on .js or .ts files.
6873
const targetFiles = diff.split('\n').filter(line => line.match(/(js|ts)$/));
6974
if (targetFiles.length === 0) return;

0 commit comments

Comments
 (0)