Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Canonicalization: combine `text-*` and `leading-*` classes ([#19396](https://github.com/tailwindlabs/tailwindcss/pull/19396))
- Correctly handle duplicate CLI arguments ([#19416](https://github.com/tailwindlabs/tailwindcss/pull/19416))
- Don’t emit color-mix fallback rules inside `@keyframes` ([#19419](https://github.com/tailwindlabs/tailwindcss/pull/19419))
- CLI: Don't hang when output is `/dev/stdout` ([#19421](https://github.com/tailwindlabs/tailwindcss/pull/19421))

### Added

Expand Down
17 changes: 13 additions & 4 deletions packages/@tailwindcss-cli/src/commands/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ export function drainStdin() {
}

export async function outputFile(file: string, contents: string) {
try {
let currentContents = await fs.readFile(file, 'utf8')
if (currentContents === contents) return // Skip writing the file
} catch {}
// Check for special files like `/dev/stdout` or pipes. We don't want to read from these as that
// will hang the process until the file descriptors are closed.
let isSpecialFile = await fs
.stat(file)
.then((stats) => stats.isCharacterDevice() || stats.isFIFO())
.catch(() => false)

if (!isSpecialFile) {
try {
let currentContents = await fs.readFile(file, 'utf8')
if (currentContents === contents) return // Skip writing the file
} catch {}
}

// Ensure the parent directories exist
await fs.mkdir(path.dirname(file), { recursive: true })
Expand Down