diff --git a/scripts/eslint.ts b/scripts/eslint.ts index ae2f4137..b6024abe 100644 --- a/scripts/eslint.ts +++ b/scripts/eslint.ts @@ -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')) { @@ -75,6 +77,7 @@ export async function main() { continue; case 2: + hasFailed = true; log.error( `${ colors.isColorSupported ? colors.bold(colors.red('FAILED')) : 'FAILED' @@ -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); +}); diff --git a/scripts/prettier.ts b/scripts/prettier.ts index 6a926f4b..5472e2df 100644 --- a/scripts/prettier.ts +++ b/scripts/prettier.ts @@ -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; } @@ -74,7 +75,8 @@ export async function main() { } ); - continue; + hasFailed = true; + break; } log.info( @@ -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); +});