diff --git a/CHANGELOG.md b/CHANGELOG.md index 449ccc635fa1..e7a9320ca13c 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 c75b719da8eb..ebb4aa38b6bf 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 251f470220cd..893a8c955c6f 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 79a5463a8332..b7fb2d93294b 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 f61eadc15fe4..bea85a09c838 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) + } } ) }