Skip to content

Commit fc4270c

Browse files
feat: allow installing of multiple versions simultaneously (#35)
1 parent 9184d5c commit fc4270c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/installer.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ export class Installer extends EventEmitter {
114114
// no current version
115115
}
116116

117-
if (this.installing) {
118-
this.setState(this.installing, InstallState.installing);
119-
}
117+
this.installing.forEach((version) => {
118+
this.setState(version, InstallState.installing);
119+
});
120120

121121
// already downloaded...
122122
const str = `^electron-v(.*)-${process.platform}-${process.arch}.zip$`;
@@ -274,19 +274,23 @@ export class Installer extends EventEmitter {
274274
return promise;
275275
}
276276

277-
/** the currently-installing version, if any */
278-
private installing: string | undefined;
277+
/** keep a track of all currently installing versions */
278+
private installing = new Set<string>();
279279

280280
public async install(
281281
version: string,
282282
opts?: Partial<InstallerParams>,
283283
): Promise<string> {
284284
const d = debug(`fiddle-core:Installer:${version}:install`);
285285
const { electronInstall } = this.paths;
286+
const isVersionInstalling = this.installing.has(version);
286287
const electronExec = Installer.getExecPath(electronInstall);
287288

288-
if (this.installing) throw new Error(`Currently installing "${version}"`);
289-
this.installing = version;
289+
if (isVersionInstalling) {
290+
throw new Error(`Currently installing "${version}"`);
291+
}
292+
293+
this.installing.add(version);
290294

291295
// see if the current version (if any) is already `version`
292296
const { installedVersion } = this;
@@ -313,7 +317,7 @@ export class Installer extends EventEmitter {
313317
this.setState(version, InstallState.installed);
314318
}
315319

316-
delete this.installing;
320+
this.installing.delete(version);
317321

318322
// return the full path to the electron executable
319323
d(inspect({ electronExec, version }));

0 commit comments

Comments
 (0)