Skip to content

Commit 52f1745

Browse files
authored
fix: skip template prompt if --template is used (#5057)
The `webstudio init` command was prompting for a template even if `--template` was used. This fix avoids that behavior.
1 parent 3d6b71d commit 52f1745

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/cli/src/commands/init-flow.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const initFlow = async (
3535
const isProjectConfigured = await isFileExists(".webstudio/config.json");
3636
let shouldInstallDeps = false;
3737
let folderName: undefined | string;
38-
let projectTemplate: ProjectTemplates | undefined = undefined;
38+
let projectTemplate: ProjectTemplates | undefined;
3939

4040
if (isProjectConfigured === false) {
4141
const shouldCreateFolder = exitIfCancelled(
@@ -71,12 +71,14 @@ export const initFlow = async (
7171

7272
await link({ link: shareLink });
7373

74-
projectTemplate = exitIfCancelled(
75-
await select({
76-
message: "Where would you like to deploy your project?",
77-
options: PROJECT_TEMPLATES,
78-
})
79-
);
74+
if (!options.template.length) {
75+
projectTemplate = exitIfCancelled(
76+
await select({
77+
message: "Where would you like to deploy your project?",
78+
options: PROJECT_TEMPLATES,
79+
})
80+
);
81+
}
8082

8183
shouldInstallDeps = exitIfCancelled(
8284
await confirm({
@@ -91,7 +93,7 @@ export const initFlow = async (
9193
We need to request for deploy target here as the current flow is running in a existing project.
9294
*/
9395

94-
if (projectTemplate === undefined) {
96+
if (!options.template.length && projectTemplate === undefined) {
9597
projectTemplate = exitIfCancelled(
9698
await select({
9799
message: "Where would you like to deploy your project?",
@@ -104,9 +106,9 @@ export const initFlow = async (
104106

105107
await build({
106108
...options,
107-
...(projectTemplate && {
108-
template: mapToTemplatesFromOptions([projectTemplate]),
109-
}),
109+
template: projectTemplate
110+
? mapToTemplatesFromOptions([projectTemplate])
111+
: options.template,
110112
});
111113

112114
if (shouldInstallDeps === true) {

0 commit comments

Comments
 (0)