Skip to content

Commit c3d3e1f

Browse files
committed
Add prompt for existing directory in init flow
Closes #1370
1 parent e37ce8d commit c3d3e1f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/cli/src/commands/init.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,18 @@ async function processInitForm(
634634
name: 'directory',
635635
message: 'Directory to create the subgraph in',
636636
initial: () => initDirectory || getSubgraphBasename(subgraphName),
637-
validate: value =>
638-
filesystem.exists(value || initDirectory || getSubgraphBasename(subgraphName))
639-
? 'Directory already exists'
640-
: true,
641637
},
642638
]);
643639

640+
if (
641+
filesystem.exists(directory) &&
642+
!(await prompt.confirm(
643+
'Directory already exists, do you want to initialize the subgraph here ?',
644+
false,
645+
))
646+
)
647+
return;
648+
644649
let choices = (await AVAILABLE_NETWORKS())?.[
645650
product === 'subgraph-studio' ? 'studio' : 'hostedService'
646651
];

0 commit comments

Comments
 (0)