Skip to content

Commit 830f054

Browse files
committed
refactor
1 parent 0313f02 commit 830f054

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/cli.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ let env = {
2323
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
2424
}
2525

26+
let configs = {
27+
tailwind: 'tailwind.config.js',
28+
postcss: 'postcss.config.js',
29+
}
30+
2631
// ---
2732

2833
function indentRecursive(node, indent = 0) {
@@ -160,11 +165,11 @@ let commands = {
160165
init: {
161166
run: init,
162167
args: {
163-
'--full': { type: Boolean, description: 'Initialize a full `tailwind.config.js` file' },
164-
'--postcss': { type: Boolean, description: 'Initialize a `postcss.config.js` file' },
168+
'--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
169+
'--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
165170
'--types': {
166171
type: Boolean,
167-
description: 'Add TypeScript types for the `tailwind.config.js` file',
172+
description: `Add TypeScript types for the \`${configs.tailwind}\` file`,
168173
},
169174
'-f': '--full',
170175
'-p': '--postcss',
@@ -340,7 +345,7 @@ run()
340345
function init() {
341346
let messages = []
342347

343-
let tailwindConfigLocation = path.resolve(args['_'][1] ?? './tailwind.config.js')
348+
let tailwindConfigLocation = path.resolve(args['_'][1] ?? `./${configs.tailwind}`)
344349
if (fs.existsSync(tailwindConfigLocation)) {
345350
messages.push(`${path.basename(tailwindConfigLocation)} already exists.`)
346351
} else {
@@ -367,7 +372,7 @@ function init() {
367372
}
368373

369374
if (args['--postcss']) {
370-
let postcssConfigLocation = path.resolve('./postcss.config.js')
375+
let postcssConfigLocation = path.resolve(`./${configs.postcss}`)
371376
if (fs.existsSync(postcssConfigLocation)) {
372377
messages.push(`${path.basename(postcssConfigLocation)} already exists.`)
373378
} else {
@@ -421,7 +426,7 @@ async function build() {
421426
let configPath = args['--config']
422427
? args['--config']
423428
: ((defaultPath) => (fs.existsSync(defaultPath) ? defaultPath : null))(
424-
path.resolve('./tailwind.config.js')
429+
path.resolve(`./${configs.tailwind}`)
425430
)
426431

427432
async function loadPostCssPlugins() {

0 commit comments

Comments
 (0)