Skip to content

Commit 9e006c9

Browse files
committed
build all flags upfront
Right now the only command is the build command and we have to parse the flags either way (either for the help or for the build itself). This simplifies the code a bit, because `-o` and `--output` will be normalised.
1 parent 640d208 commit 9e006c9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/@tailwindcss-cli/src/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ const sharedOptions = {
99
'--help': { type: 'boolean', description: 'Display usage information', alias: '-h' },
1010
} satisfies Arg
1111

12-
const shared = args(sharedOptions)
13-
const command = shared._[0]
12+
const flags = args({
13+
...build.options(),
14+
...sharedOptions,
15+
})
16+
const command = flags._[0]
1417

1518
// Right now we don't support any sub-commands. Let's show the help message
1619
// instead.
@@ -33,11 +36,7 @@ if (command) {
3336
//
3437
// - `tailwindcss -o output.css` // should run the build command, not show the help message
3538
// - `tailwindcss > output.css` // should run the build command, not show the help message
36-
if (
37-
(process.stdout.isTTY &&
38-
!process.argv.slice(2).some((flag) => flag === '-o' || flag === '--output')) ||
39-
shared['--help']
40-
) {
39+
if ((process.stdout.isTTY && !flags['--output']) || flags['--help']) {
4140
help({
4241
usage: ['tailwindcss [--input input.css] [--output output.css] [--watch] [options…]'],
4342
options: { ...build.options(), ...sharedOptions },
@@ -46,4 +45,4 @@ if (
4645
}
4746

4847
// Handle the build command
49-
build.handle(args(build.options()))
48+
build.handle(flags)

0 commit comments

Comments
 (0)