diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f6ba3b5650f..377ef036230a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,9 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Vite: Ensure that updates to an imported CSS file are properly propagated after updating templates ([#17347](https://github.com/tailwindlabs/tailwindcss/pull/17347)) - Fix class extraction followed by `(` in Pug ([#17320](https://github.com/tailwindlabs/tailwindcss/pull/17320)) +- Vite: Ensure that updates to an imported CSS file are properly propagated after updating templates ([#17347](https://github.com/tailwindlabs/tailwindcss/pull/17347)) - Pre process `Slim` templates embedded in Ruby files ([#17336](https://github.com/tailwindlabs/tailwindcss/pull/17336)) +- Error when input and output files resolve to the same file when using the CLI ([#17311](https://github.com/tailwindlabs/tailwindcss/pull/17311)) ### [4.0.15] - 2025-03-20 diff --git a/integrations/cli/index.test.ts b/integrations/cli/index.test.ts index 1e1fca38b324..487c88e40b76 100644 --- a/integrations/cli/index.test.ts +++ b/integrations/cli/index.test.ts @@ -1387,6 +1387,76 @@ test( }, ) +test( + 'fails when input file does not exist', + { + fs: { + 'package.json': json` + { + "dependencies": { + "tailwindcss": "workspace:^", + "@tailwindcss/cli": "workspace:^" + } + } + `, + }, + }, + async ({ exec, expect }) => { + await expect(exec('pnpm tailwindcss --input index.css --output dist/out.css')).rejects.toThrow( + /Specified input file.*does not exist./, + ) + }, +) + +test( + 'fails when input file and output file are the same', + { + fs: { + 'package.json': json` + { + "dependencies": { + "tailwindcss": "workspace:^", + "@tailwindcss/cli": "workspace:^" + } + } + `, + 'input.css': '', + }, + }, + async ({ exec, expect }) => { + await expect(exec('pnpm tailwindcss --input input.css --output input.css')).rejects.toThrow( + /Specified input file.*and output file.*are identical./, + ) + await expect( + exec('pnpm tailwindcss --input input.css --output ./src/../input.css'), + ).rejects.toThrow(/Specified input file.*and output file.*are identical./) + }, +) + +test( + 'input and output flags can be the same if `-` is used', + { + fs: { + 'package.json': json` + { + "dependencies": { + "tailwindcss": "workspace:^", + "@tailwindcss/cli": "workspace:^" + } + } + `, + 'index.html': html`
`, + }, + }, + async ({ exec, expect }) => { + expect( + await exec('pnpm tailwindcss --input - --output -', undefined, { + stdin: '@tailwind utilities;', + }), + ).toContain(candidate`flex`) + }, +) + function withBOM(text: string): string { return '\uFEFF' + text } diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index 6991e7bf0f16..4e9c99e23459 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -95,6 +95,17 @@ export async function handle(args: Result