Skip to content

Commit

Permalink
feat(create-waku): --project-name option (#1232)
Browse files Browse the repository at this point in the history
Fixes #1208

---------

Co-authored-by: Daishi Kato <[email protected]>
  • Loading branch information
rmarscher and dai-shi authored Feb 17, 2025
1 parent 17cc234 commit ff9c9ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/create-waku/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const { values } = parseArgs({
example: {
type: 'string',
},
'project-name': {
type: 'string',
},
help: {
type: 'boolean',
short: 'h',
Expand Down Expand Up @@ -98,22 +101,22 @@ async function doPrompts() {
const templateNames = await getTemplateNames(templateRoot);

const defaultProjectName = 'waku-project';
let targetDir = '';
let targetDir = values['project-name'] || defaultProjectName;

try {
const result = await prompts(
[
{
name: 'projectName',
type: 'text',
type: values['project-name'] ? null : 'text',
message: 'Project Name',
initial: defaultProjectName,
onState: (state: any) => (targetDir = String(state.value).trim()),
},
{
name: 'shouldOverwrite',
type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'),
message: `${targetDir || defaultProjectName} is not empty. Remove existing files and continue?`,
message: `${targetDir} is not empty. Remove existing files and continue?`,
},
{
name: 'overwriteChecker',
Expand Down Expand Up @@ -169,6 +172,7 @@ Usage: ${commands.create} [options]
Options:
--choose Choose from the template list
--example Specify an example use as a template
--project-name Specify a project name
-h, --help Display this help message
`);
}
Expand Down

0 comments on commit ff9c9ef

Please sign in to comment.