Skip to content

Commit 4852c35

Browse files
authored
fix(schematics): Address ng add console lock up (#3151)
Fixes #3145 #3121
1 parent 520930b commit 4852c35

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/schematics/setup/prompts.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const isSite = (elem: FirebaseHostingSite | fuzzy.FilterResult<FirebaseHostingSi
2424
return (elem as { original: FirebaseHostingSite }).original === undefined;
2525
};
2626

27-
export const searchProjects = (promise: Promise<FirebaseProject[]>) =>
28-
(_: any, input: string) => promise.then(projects => {
27+
export const searchProjects = (projects: FirebaseProject[]) =>
28+
async (_: any, input: string) => {
2929
projects.unshift({
3030
projectId: NEW_OPTION,
3131
displayName: '[CREATE NEW PROJECT]'
@@ -47,10 +47,10 @@ export const searchProjects = (promise: Promise<FirebaseProject[]>) =>
4747
value: original.projectId
4848
};
4949
});
50-
});
50+
};
5151

52-
export const searchApps = (promise: Promise<FirebaseApp[]>) =>
53-
(_: any, input: string) => promise.then(apps => {
52+
export const searchApps = (apps: FirebaseApp[]) =>
53+
async (_: any, input: string) => {
5454
apps.unshift({
5555
appId: NEW_OPTION,
5656
displayName: '[CREATE NEW APP]',
@@ -72,10 +72,10 @@ export const searchApps = (promise: Promise<FirebaseApp[]>) =>
7272
value: shortAppId(original),
7373
};
7474
});
75-
});
75+
};
7676

77-
export const searchSites = (promise: Promise<FirebaseHostingSite[]>) =>
78-
(_: any, input: string) => promise.then(sites => {
77+
export const searchSites = (sites: FirebaseHostingSite[]) =>
78+
async (_: any, input: string) => {
7979
sites.unshift({
8080
name: NEW_OPTION,
8181
defaultUrl: '[CREATE NEW SITE]',
@@ -97,7 +97,7 @@ export const searchSites = (promise: Promise<FirebaseHostingSite[]>) =>
9797
value: shortSiteName(original),
9898
};
9999
});
100-
});
100+
};
101101

102102

103103
type Prompt = <K extends string, U= unknown>(questions: { name: K, source: (...args) =>
@@ -146,7 +146,7 @@ export const userPrompt = async (options: {}): Promise<Record<string, any>> => {
146146

147147
export const projectPrompt = async (defaultProject: string|undefined, options: {}) => {
148148
const firebaseTools = await getFirebaseTools();
149-
const projects = firebaseTools.projects.list(options);
149+
const projects = await firebaseTools.projects.list(options);
150150
const { projectId } = await autocomplete({
151151
type: 'autocomplete',
152152
name: 'projectId',
@@ -174,7 +174,7 @@ export const projectPrompt = async (defaultProject: string|undefined, options: {
174174

175175
export const appPrompt = async ({ projectId: project }: FirebaseProject, defaultAppId: string|undefined, options: {}) => {
176176
const firebaseTools = await getFirebaseTools();
177-
const apps = firebaseTools.apps.list('web', { ...options, project });
177+
const apps = await firebaseTools.apps.list('web', { ...options, project });
178178
const { appId } = await autocomplete({
179179
type: 'autocomplete',
180180
name: 'appId',
@@ -196,7 +196,7 @@ export const appPrompt = async ({ projectId: project }: FirebaseProject, default
196196

197197
export const sitePrompt = async ({ projectId: project }: FirebaseProject, options: {}) => {
198198
const firebaseTools = await getFirebaseTools();
199-
const sites = firebaseTools.hosting.sites.list({ ...options, project }).then(it => {
199+
const sites = await firebaseTools.hosting.sites.list({ ...options, project }).then(it => {
200200
if (it.sites.length === 0) {
201201
// newly created projects don't return their default site, stub one
202202
return [{
@@ -214,7 +214,7 @@ export const sitePrompt = async ({ projectId: project }: FirebaseProject, option
214214
name: 'siteName',
215215
source: searchSites(sites),
216216
message: 'Please select a hosting site:',
217-
default: _ => sites.then(it => shortSiteName(it.find(it => it.type === DEFAULT_SITE_TYPE))),
217+
default: _ => shortSiteName(sites.find(site => site.type === DEFAULT_SITE_TYPE)),
218218
});
219219
if (siteName === NEW_OPTION) {
220220
const { subdomain } = await inquirer.prompt({

0 commit comments

Comments
 (0)