diff --git a/CHANGELOG.md b/CHANGELOG.md index 449ccc63..e7a9320c 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 c75b719d..ebb4aa38 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 251f4702..893a8c95 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 79a5463a..b7fb2d93 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 f61eadc1..bea85a09 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) + } } ) }