Skip to content

Commit

Permalink
fix: exit code 1 with bulid errors
Browse files Browse the repository at this point in the history
closes #196
  • Loading branch information
danielroe committed Dec 6, 2020
1 parent d2617ec commit 95f5f2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cli/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function run(
)
} catch (e) {
pkg.logger.error(`Error running ${bold(fullCommand)}\n`, gray(e))
process.exit(1)
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import { run as runFile } from './commands/run'

import { time, timeEnd, RemoveFirst } from './utils'

let wasErrored = false
const error = consola.error.bind(consola)
consola.error = (message: any, ...args: any[]) => {
wasErrored = true
error(message, ...args)
}

time('load root package')
let rootPackage: Package
try {
Expand Down Expand Up @@ -117,6 +124,10 @@ timeEnd('load CLI')

cli.parse()

process.on('beforeExit', () => {

This comment has been minimized.

Copy link
@pi0

pi0 Dec 7, 2020

(not sure but i think some signals like SIGINT/SIGUSR* may take priority over this, causing wrong exit code still just a guess)

if (wasErrored) process.exit(1)
})

process.on('unhandledRejection', err => {
consola.error(err)
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const build = async (
await runInParallel(asArray(config.output), async outputConfig => {
if (!outputConfig) {
pkg.logger.error('No build defined in generated config.')
return
process.exit(1)
}

const { output } = await bundle.write(outputConfig)
Expand Down

0 comments on commit 95f5f2e

Please sign in to comment.