This commit is contained in:
@@ -12,7 +12,7 @@ const tracked = execFileSync('git', ['diff', '--name-only', '--diff-filter=ACMR'
|
||||
});
|
||||
const untracked = execFileSync('git', ['ls-files', '--others', '--exclude-standard'], { cwd: root, encoding: 'utf8' });
|
||||
const files = [...new Set(`${tracked}\n${untracked}`.split(/\r?\n/).filter(Boolean))].filter((file) =>
|
||||
/^(?:src|api\/src|tools)\/.+\.(?:[cm]?[jt]sx?)$/.test(file),
|
||||
/^(?:src|api\/src|tools)\/.+\.(?:[cm]?[jt]sx?|css)$/.test(file),
|
||||
);
|
||||
|
||||
if (!files.length) {
|
||||
@@ -20,12 +20,15 @@ if (!files.length) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const executable =
|
||||
process.platform === 'win32'
|
||||
? `${mode === 'lint' ? 'eslint' : 'prettier'}.cmd`
|
||||
: mode === 'lint'
|
||||
? 'eslint'
|
||||
: 'prettier';
|
||||
const args = mode === 'lint' ? files : ['--check', ...files];
|
||||
const result = spawnSync(resolve(root, 'node_modules/.bin', executable), args, { cwd: root, stdio: 'inherit' });
|
||||
const args = mode === 'lint' ? files.filter((file) => !file.endsWith('.css')) : ['--check', ...files];
|
||||
if (mode === 'lint' && !args.length) {
|
||||
console.log('No changed code files require lint.');
|
||||
process.exit(0);
|
||||
}
|
||||
const executable = process.execPath;
|
||||
const moduleEntry = resolve(
|
||||
root,
|
||||
mode === 'lint' ? 'node_modules/eslint/bin/eslint.js' : 'node_modules/prettier/bin/prettier.cjs',
|
||||
);
|
||||
const result = spawnSync(executable, [moduleEntry, ...args], { cwd: root, stdio: 'inherit' });
|
||||
process.exit(result.status ?? 1);
|
||||
|
||||
Reference in New Issue
Block a user