Skip to content

Commit 80bd185

Browse files
committed
ensure --name flag suppresses interactive name prompt
1 parent 44d8ba4 commit 80bd185

File tree

1 file changed

+11
-3
lines changed
  • packages/app/src/cli/commands/app

1 file changed

+11
-3
lines changed

packages/app/src/cli/commands/app/init.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ export default class Init extends AppLinkedCommand {
117117
}
118118
developerPlatformClient = selectDeveloperPlatformClient({organization: org})
119119
const {organization, apps, hasMorePages} = await developerPlatformClient.orgAndApps(org.id)
120-
selectAppResult = await selectAppOrNewAppName(name, apps, hasMorePages, organization, developerPlatformClient)
120+
selectAppResult = await selectAppOrNewAppName(
121+
flags.name !== undefined,
122+
name,
123+
apps,
124+
hasMorePages,
125+
organization,
126+
developerPlatformClient,
127+
)
121128
appName = selectAppResult.result === 'new' ? selectAppResult.name : selectAppResult.app.title
122129
}
123130

@@ -173,18 +180,19 @@ export type SelectAppOrNewAppNameResult =
173180
* But doesn't create the app yet, the app creation is deferred and is responsibility of the caller.
174181
*/
175182
async function selectAppOrNewAppName(
183+
nameProvidedAsFlag: boolean,
176184
localAppName: string,
177185
apps: MinimalOrganizationApp[],
178186
hasMorePages: boolean,
179187
org: Organization,
180188
developerPlatformClient: DeveloperPlatformClient,
181189
): Promise<SelectAppOrNewAppNameResult> {
182-
let createNewApp = apps.length === 0
190+
let createNewApp = apps.length === 0 || nameProvidedAsFlag
183191
if (!createNewApp) {
184192
createNewApp = await createAsNewAppPrompt()
185193
}
186194
if (createNewApp) {
187-
const name = await appNamePrompt(localAppName)
195+
const name = nameProvidedAsFlag ? localAppName : await appNamePrompt(localAppName)
188196
return {result: 'new', name, org}
189197
} else {
190198
const app = await selectAppPrompt(searchForAppsByNameFactory(developerPlatformClient, org.id), apps, hasMorePages)

0 commit comments

Comments
 (0)