Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 5739167

Browse files
committed
fix(preapre): Correct work with async await array
1 parent 9753c30 commit 5739167

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

src/commands/prepare.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ export class Prepare extends Command {
9797
) {
9898
return new Promise(async (resolve, reject) => {
9999
const errors: any[] = [];
100-
libs.filter(lib => lib.root).forEach(async (lib: { root: string }) => {
100+
const eachLibs: { root: string }[] = libs.filter(lib => lib.root);
101+
for (const lib of eachLibs) {
101102
try {
102103
await VersionUpdater.run([resolvePath(folder, lib.root), '--root', resolvePath(folder)]);
103104
} catch (error) {
104105
errors.push(error);
105106
}
106-
});
107+
}
107108
if (errors.length) {
108109
reject(errors);
109110
} else {
@@ -116,20 +117,22 @@ export class Prepare extends Command {
116117
) {
117118
return new Promise(async (resolve, reject) => {
118119
const errors: any[] = [];
119-
apps.filter(app => app.sourceRoot).forEach(async (app: { sourceRoot: string }) => {
120+
const eachApps: { sourceRoot: string }[] = apps.filter(app => app.sourceRoot);
121+
for (const app of eachApps) {
120122
try {
121123
await MakeTsList.run([resolvePath(folder, app.sourceRoot, 'app')]);
122124
} catch (error) {
123125
errors.push(error);
124126
}
125-
});
126-
libs.filter(lib => lib.sourceRoot).forEach(async (lib: { sourceRoot: string }) => {
127+
}
128+
const eachLibs: { sourceRoot: string }[] = libs.filter(lib => lib.sourceRoot);
129+
for (const lib of eachLibs) {
127130
try {
128131
await MakeTsList.run([resolvePath(folder, lib.sourceRoot)]);
129132
} catch (error) {
130133
errors.push(error);
131134
}
132-
});
135+
}
133136
if (errors.length) {
134137
reject(errors);
135138
} else {
@@ -142,27 +145,27 @@ export class Prepare extends Command {
142145
) {
143146
return new Promise(async (resolve, reject) => {
144147
const errors: any[] = [];
145-
apps.filter(app => app.sourceRoot).forEach(async (app: { sourceRoot: string }) => {
148+
const eachApps: { sourceRoot: string }[] = apps.filter(app => app.sourceRoot);
149+
for (const app of eachApps) {
146150
try {
147151
await Translate.run([resolvePath(folder, app.sourceRoot, 'app')]);
148152
} catch (error) {
149153
errors.push(error);
150154
}
151-
});
152-
libs.filter(lib => lib.sourceRoot).forEach(async (lib: { sourceRoot: string }) => {
155+
}
156+
const eachLibs: { sourceRoot: string }[] = libs.filter(lib => lib.sourceRoot);
157+
for (const lib of eachLibs) {
153158
try {
154159
await Translate.run([resolvePath(folder, lib.sourceRoot)]);
155160
} catch (error) {
156161
errors.push(error);
157162
}
158-
});
159-
setTimeout(() => {
160-
if (errors.length) {
161-
reject(errors);
162-
} else {
163-
resolve();
164-
}
165-
}, 1000);
163+
}
164+
if (errors.length) {
165+
reject(errors);
166+
} else {
167+
resolve();
168+
}
166169
});
167170
}
168171
}

0 commit comments

Comments
 (0)