Skip to content

Commit

Permalink
feat: change -s flag to -f|--force and make it default
Browse files Browse the repository at this point in the history
  • Loading branch information
maverox committed Jun 8, 2024
1 parent e6add83 commit 4ac8bf0
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/create-webpack-app/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,32 @@ const defaultValues = {
},
};

program.version("1.0.0", "-v, --version");
program.helpOption("-h, --help", "Display help for command");
program
.version("1.0.0", "-v, --version")
.usage("[command] [options]")
.helpOption("-h, --help", "Display help for command")
.description("A CLI tool to generate a Webpack project");

program
.command("init")
.command("init", { isDefault: true })
.aliases(["i", "c", "create", "new"])
.description("Initialize a new Webpack project")
.option("-s, --skip", "Skip the prompt and use the default values", false)
.option("-f, --force", "Force the generator actions to override existing files", false)
.action(function (opts) {
.argument("[projectPath]", "Path to create the project")
.argument("[projectName]", "Name of the project")
.option("-f, --force", "Skip the prompt and use the default values", false)
.action(function (projectName, projectPath, opts) {
console.log("Initializing a new Webpack project");
const { skip, force } = opts;
const { force } = opts;
const initGenerator = plop.getGenerator("init");
if (skip) {
const byPassValues = [];
if (projectName) byPassValues.push(projectName);
if (projectPath) byPassValues.push(projectPath);

if (force) {
console.log("Skipping the prompt and using the default values");
initGenerator.runActions(defaultValues.init);
} else {
initGenerator.runPrompts([]).then((answers) => {
initGenerator.runPrompts(byPassValues).then((answers) => {
initGenerator.runActions(answers);
});
}
Expand Down

0 comments on commit 4ac8bf0

Please sign in to comment.