Skip to content

Commit

Permalink
feat: detect config file if it exists to avoid prompting the user (cl…
Browse files Browse the repository at this point in the history
…oses #144)
  • Loading branch information
muhammadsammy committed Feb 7, 2021
1 parent 19a2ffc commit 69b7e55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import commander from 'commander';
import inquirer from 'inquirer';
import colors from 'colors';
import fs from 'fs';

import {GeneratedFileWriter} from './core/GeneratedFileWriter';

type TInquirerAnswers = {
Expand All @@ -23,11 +25,12 @@ commander

// Define the action of the CLI
.action(({input, output, classesFile: extra}: {[key: string]: string | void}) => {
// If a required minimum of arguments is supplied to the CLI interface...
if (input) {
const isConfigFileFound: boolean = fs.existsSync('./tailwind.config.js');
// If the config file is found or provided explicitly by the user...
if (isConfigFileFound || !!input) {
// Generate the types and write them to a file on disk
void new GeneratedFileWriter({
configFilename: input,
configFilename: isConfigFileFound ? 'tailwind.config.js' : input,
outputFilename: output,
customClassesFilename: extra,
}).write();
Expand Down

0 comments on commit 69b7e55

Please sign in to comment.