Skip to content

Commit

Permalink
fix(misc): format:check not checking all affected files (#9152)
Browse files Browse the repository at this point in the history
  • Loading branch information
miluoshi committed Mar 2, 2022
1 parent efedd2e commit ea33428
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/workspace/src/command-line/format.ts
Expand Up @@ -49,7 +49,13 @@ export async function format(
chunkList.forEach((chunk) => write(chunk));
break;
case 'check':
chunkList.forEach((chunk) => check(chunk));
const pass = chunkList.reduce(
(pass, chunk) => check(chunk) && pass,
true
);
if (!pass) {
process.exit(1);
}
break;
}
}
Expand Down Expand Up @@ -142,18 +148,17 @@ function write(patterns: string[]) {
}
}

function check(patterns: string[]) {
if (patterns.length > 0) {
try {
execSync(
`node "${PRETTIER_PATH}" --list-different ${patterns.join(' ')}`,
{
stdio: [0, 1, 2],
}
);
} catch {
process.exit(1);
}
function check(patterns: string[]): boolean {
if (patterns.length === 0) {
return true;
}
try {
execSync(`node "${PRETTIER_PATH}" --list-different ${patterns.join(' ')}`, {
stdio: [0, 1, 2],
});
return true;
} catch {
return false;
}
}

Expand Down

0 comments on commit ea33428

Please sign in to comment.