From 1874798bddf1ffbdc3abd8a7cb16a02fd42856ae Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Tue, 28 Feb 2023 16:50:06 +0100 Subject: [PATCH] Ensure CLI builds have a non-zero exit code on failure (#10703) * ensure simple builds have a non-zero exit code on failure This is not used for the watcher. * update changelog --- CHANGELOG.md | 1 + src/cli/build/index.js | 5 ++++- src/cli/build/plugin.js | 6 +++++- src/oxide/cli/build/index.ts | 5 ++++- src/oxide/cli/build/plugin.ts | 6 +++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449ccc635..e7a9320ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Disallow multiple selectors in arbitrary variants ([#10655](https://github.com/tailwindlabs/tailwindcss/pull/10655)) - Sort class lists deterministically for Prettier plugin ([#10672](https://github.com/tailwindlabs/tailwindcss/pull/10672)) +- Ensure CLI builds have a non-zero exit code on failure ([#10703](https://github.com/tailwindlabs/tailwindcss/pull/10703)) ### Changed diff --git a/src/cli/build/index.js b/src/cli/build/index.js index c75b719da..ebb4aa38b 100644 --- a/src/cli/build/index.js +++ b/src/cli/build/index.js @@ -44,6 +44,9 @@ export async function build(args, configs) { await processor.watch() } else { - await processor.build() + await processor.build().catch((e) => { + console.error(e) + process.exit(1) + }) } } diff --git a/src/cli/build/plugin.js b/src/cli/build/plugin.js index 251f47022..893a8c955 100644 --- a/src/cli/build/plugin.js +++ b/src/cli/build/plugin.js @@ -383,7 +383,11 @@ export async function createProcessor(args, cliConfigPath) { // The watcher will start watching the imported CSS files and will be // resilient to future errors. - console.error(err) + if (state.watcher) { + console.error(err) + } else { + return Promise.reject(err) + } } ) } diff --git a/src/oxide/cli/build/index.ts b/src/oxide/cli/build/index.ts index 79a5463a8..b7fb2d932 100644 --- a/src/oxide/cli/build/index.ts +++ b/src/oxide/cli/build/index.ts @@ -42,6 +42,9 @@ export async function build(args, configs) { await processor.watch() } else { - await processor.build() + await processor.build().catch((e) => { + console.error(e) + process.exit(1) + }) } } diff --git a/src/oxide/cli/build/plugin.ts b/src/oxide/cli/build/plugin.ts index f61eadc15..bea85a09c 100644 --- a/src/oxide/cli/build/plugin.ts +++ b/src/oxide/cli/build/plugin.ts @@ -380,7 +380,11 @@ export async function createProcessor(args, cliConfigPath) { // The watcher will start watching the imported CSS files and will be // resilient to future errors. - console.error(err) + if (state.watcher) { + console.error(err) + } else { + return Promise.reject(err) + } } ) }