Add --silent option to suppress output in @tailwindcss/cli#20100
Conversation
WalkthroughThis PR adds a --silent CLI flag to the Tailwind build command. The option is declared in options(), the initial header/blank line and all "Done in …" timing messages are now printed only when --silent is not set (watch early-return, watch rebuild completion, initial non-watch completion), and a Vitest verifies that loud runs include the banner/timing while silent runs omit them and both produce the expected CSS. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
integrations/cli/index.test.ts (1)
2240-2242: ⚡ Quick winAdd an assertion path for the long-form
--quietflag.Line 2240 currently exercises only
-q. Since the public CLI contract includes--quiettoo, add one explicit run with--quietto lock that in.✅ Minimal test extension
let quietOutput = await exec('pnpm tailwindcss --input index.css --output dist/quiet.css -q') expect(quietOutput).not.toContain('Done in') expect(quietOutput).toContain('tailwindcss v') + let quietLongOutput = await exec( + 'pnpm tailwindcss --input index.css --output dist/quiet-long.css --quiet', + ) + expect(quietLongOutput).not.toContain('Done in') + await fs.expectFileToContain('dist/quiet.css', [candidate`flex`]) + await fs.expectFileToContain('dist/quiet-long.css', [candidate`flex`])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@integrations/cli/index.test.ts` around lines 2240 - 2242, The test currently only exercises the short flag `-q`; add an explicit run that uses the long-form `--quiet` flag by calling the same helper `exec` (e.g., assign to a new variable like `quietOutputLong`) with the command string including `--quiet` instead of `-q`, and assert the same expectations as the existing assertions (that the output does not contain 'Done in' and does contain 'tailwindcss v') so the CLI contract for `--quiet` is locked in.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@integrations/cli/index.test.ts`:
- Around line 2240-2242: The test currently only exercises the short flag `-q`;
add an explicit run that uses the long-form `--quiet` flag by calling the same
helper `exec` (e.g., assign to a new variable like `quietOutputLong`) with the
command string including `--quiet` instead of `-q`, and assert the same
expectations as the existing assertions (that the output does not contain 'Done
in' and does contain 'tailwindcss v') so the CLI contract for `--quiet` is
locked in.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c1c88e82-950b-49e2-9dcc-7387a89c7452
📒 Files selected for processing (2)
integrations/cli/index.test.tspackages/@tailwindcss-cli/src/commands/build/index.ts
Confidence Score: 5/5The change is narrow in scope — a new opt-in boolean flag that only suppresses informational stderr output — and does not touch any build logic, CSS compilation, or file I/O. Every informational No files require special attention. Reviews (3): Last reviewed commit: "update changelog" | Re-trigger Greptile |
--quiet option to suppress "Done in [x]" build timing messages--silent option to suppress output in @tailwindcss/cli
There was a problem hiding this comment.
🧹 Nitpick comments (1)
integrations/cli/index.test.ts (1)
2237-2245: ⚡ Quick winAssert loud-mode banner explicitly to lock in default behavior.
The test currently verifies silent-mode banner suppression, but not that non-silent mode still emits the banner. Adding that assertion protects the non-silent contract.
Suggested test tweak
let output = await exec('pnpm tailwindcss --input index.css --output dist/loud.css') expect(output).toContain('Done in') + expect(output).toContain('tailwindcss v')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@integrations/cli/index.test.ts` around lines 2237 - 2245, The loud-mode test currently only checks for 'Done in' but doesn't assert that the non-silent banner is emitted; update the test around the exec call (the variable output returned by exec('pnpm tailwindcss --input index.css --output dist/loud.css')) to also assert that output contains the tailwind banner (for example assert output contains 'tailwindcss v' or the expected banner string) so the default non-silent behavior is locked in while keeping the existing silent-mode assertions for silentOutput.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@integrations/cli/index.test.ts`:
- Around line 2237-2245: The loud-mode test currently only checks for 'Done in'
but doesn't assert that the non-silent banner is emitted; update the test around
the exec call (the variable output returned by exec('pnpm tailwindcss --input
index.css --output dist/loud.css')) to also assert that output contains the
tailwind banner (for example assert output contains 'tailwindcss v' or the
expected banner string) so the default non-silent behavior is locked in while
keeping the existing silent-mode assertions for silentOutput.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7cc0d504-5743-423f-a4ff-814ca27762b0
📒 Files selected for processing (2)
integrations/cli/index.test.tspackages/@tailwindcss-cli/src/commands/build/index.ts
0ebd27e to
da6e41d
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
integrations/cli/index.test.ts (1)
2237-2244: ⚡ Quick winConsider adding assertion for banner in loud output.
The test validates that
--silentsuppresses both "Done in" and "tailwindcss v", but doesn't verify that the loud output includes "tailwindcss v". While the current test is valid, addingexpect(output).toContain('tailwindcss v')after line 2238 would make the test more thorough by explicitly verifying the banner appears in normal mode.✨ Suggested enhancement
let output = await exec('pnpm tailwindcss --input index.css --output dist/loud.css') expect(output).toContain('Done in') +expect(output).toContain('tailwindcss v') let silentOutput = await exec( 'pnpm tailwindcss --input index.css --output dist/silent.css --silent', ) expect(silentOutput).not.toContain('Done in') expect(silentOutput).not.toContain('tailwindcss v')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@integrations/cli/index.test.ts` around lines 2237 - 2244, The test currently checks that loud output contains "Done in" and silent output omits both "Done in" and "tailwindcss v", but doesn't assert that the loud output includes the banner; update the test that calls exec (the variable named output from exec('pnpm tailwindcss --input index.css --output dist/loud.css')) to also assert expect(output).toContain('tailwindcss v') immediately after the existing expect(output).toContain('Done in') so the loud mode banner is explicitly verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@integrations/cli/index.test.ts`:
- Around line 2237-2244: The test currently checks that loud output contains
"Done in" and silent output omits both "Done in" and "tailwindcss v", but
doesn't assert that the loud output includes the banner; update the test that
calls exec (the variable named output from exec('pnpm tailwindcss --input
index.css --output dist/loud.css')) to also assert
expect(output).toContain('tailwindcss v') immediately after the existing
expect(output).toContain('Done in') so the loud mode banner is explicitly
verified.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 69b1a4b5-723f-428b-a203-5fa34ece1cc4
📒 Files selected for processing (3)
CHANGELOG.mdintegrations/cli/index.test.tspackages/@tailwindcss-cli/src/commands/build/index.ts
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
RobinMalfait
left a comment
There was a problem hiding this comment.
Thanks! I changed the --quiet flag to --silent because that's the name we talked about in the linked issue. As a non-native English speaker --silent is easier compared to --quiet (I often type --quite or --quit especially when typing fast).
Additionally, I also remove the Tailwind CSS header when the --silent option is passed such that only errors are present and nothing else.
|
Thank you for merging! |
Edited by: @RobinMalfait
This PR adds a new
--silentoption to the@tailwindcss/clito suppress output (except for errors).Test plan
--silentoption was addedOriginal:
Summary
Small change to add a
--quietoption.@adamwathan previously said this type of thing sounded like a good idea:
This is helpful to keep logs high signal in some scenarios. For example, when I want AI to sift through my foreman logs, where "Done in X" becomes the dominant log message over time when running tailwind alongside other things.
Test plan
I've added an integration test.