mirror of
https://github.com/egoist/tsup.git
synced 2025-12-08 20:35:58 +00:00
fix: handle errors in worker
This commit is contained in:
parent
f6a07fdc0c
commit
4722b2edca
@ -401,8 +401,10 @@ export async function build(_options: Options) {
|
||||
},
|
||||
})
|
||||
worker.on('message', (data) => {
|
||||
if (data === 'has-error') {
|
||||
if (data === 'error') {
|
||||
process.exitCode = 1
|
||||
} else if (data === 'success') {
|
||||
process.exitCode = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -114,6 +114,7 @@ async function runRollup(options: RollupConfig) {
|
||||
)
|
||||
} catch (error) {
|
||||
console.log(`${makeLabel('dts', 'error')} Build error`)
|
||||
parentPort?.postMessage('error')
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
@ -135,9 +136,10 @@ async function watchRollup(options: {
|
||||
console.log(
|
||||
`${makeLabel('dts', 'success')} Build success in ${event.duration}ms`
|
||||
)
|
||||
parentPort?.postMessage('success')
|
||||
} else if (event.code === 'ERROR') {
|
||||
console.log(`${makeLabel('dts', 'error')} Build failed`)
|
||||
console.log(event.error)
|
||||
parentPort?.postMessage('error')
|
||||
handleError(event.error)
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user