Skip to content

Commit

Permalink
[ci] make scripts fail if lint/fmt didn't go to plan, skip build/ d…
Browse files Browse the repository at this point in the history
…irectory
  • Loading branch information
auguwu committed Jan 6, 2024
1 parent 16af0e8 commit 47770ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 8 additions & 6 deletions scripts/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export async function main() {
});

const formatter = await linter.loadFormatter('codeframe');
let hasFailed = false;

log.startGroup(`linting directory [${resolve(ROOT)}]`);
for (const file of await globby('**/*.ts')) {
if (file.includes('node_modules') || file.includes('dist')) {
Expand Down Expand Up @@ -75,6 +77,7 @@ export async function main() {
continue;

case 2:
hasFailed = true;
log.error(
`${
colors.isColorSupported ? colors.bold(colors.red('FAILED')) : 'FAILED'
Expand All @@ -99,11 +102,10 @@ export async function main() {
}

log.endGroup();
process.exit(hasFailed ? 1 : 0);
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
main().catch((ex) => {
log.error(ex);
process.exit(1);
});
}
main().catch((ex) => {
log.error(ex);
process.exit(1);
});
18 changes: 9 additions & 9 deletions scripts/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export async function main() {
throw new Error(`was unable to resolve Prettier config in [${resolve(ROOT, '.prettierrc.json')}] ?!`);
}

let hasFailed = false;
for (const file of await globby('**/*.{ts,js,md,yaml,yml,json}')) {
if (file.includes('node_modules') || file.includes('dist')) {
if (file.includes('node_modules') || file.includes('build')) {
continue;
}

Expand Down Expand Up @@ -74,7 +75,8 @@ export async function main() {
}
);

continue;
hasFailed = true;
break;
}

log.info(
Expand All @@ -95,12 +97,10 @@ export async function main() {
}

log.endGroup();
process.exit(0);
process.exit(hasFailed ? 1 : 0);
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
main().catch((ex) => {
log.error(ex);
process.exit(1);
});
}
main().catch((ex) => {
log.error(ex);
process.exit(1);
});

0 comments on commit 47770ff

Please sign in to comment.