Skip to content

Commit

Permalink
fix: Add project based tailwind config file generation
Browse files Browse the repository at this point in the history
fix: Add project based tailwind config file generation
  • Loading branch information
severinlandolt authored Jan 20, 2024
2 parents aba19a4 + 7b4fa55 commit ff76468
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function main() {
type: "confirm",
name: "proceed",
message:
"Running this command will install dependencies and overwrite your existing tailwind.config.js. Proceed?",
"Running this command will install dependencies and overwrite existing tailwind configurations. Proceed?",
initial: true,
});

Expand All @@ -95,8 +95,32 @@ async function main() {
]);
dependenciesSpinner.succeed();

const tailwindDestination = "./tailwind.config.js";
const tailwindSpinner = ora(`Configuring tailwind.config.js...`).start();
// Check the kind of project (TypeScript/JavaScript)
const isTypeScriptProject = fs.existsSync("tsconfig.json");

// Infer the name of the tailwind config file accordingly
const tailwindConfigFileName = isTypeScriptProject ? "tailwind.config.ts" : "tailwind.config.js";
const tailwindDestination = `./${tailwindConfigFileName}`;

// Check if the tailwind config file already exists
const tailwindConfigFileExists = fs.existsSync(tailwindDestination);

// If the tailwind config file already exists, prompt the user to overwrite it
// if (tailwindConfigFileExists) {
// const { overwrite } = await prompts({
// type: "confirm",
// name: "overwrite",
// message: `A ${tailwindConfigFileName} already exists. Overwrite it?`,
// initial: false,
// });

// if (!overwrite) {
// process.exit(0);
// }
// }

// Write the tailwind config file
const tailwindSpinner = ora(`Configuring ${tailwindConfigFileName}...`).start();
await fs.writeFile(
tailwindDestination,
getTailwindConfig(frameworkConfigType),
Expand Down

0 comments on commit ff76468

Please sign in to comment.