Skip to content

Commit 46da22f

Browse files
authored
feat(cli): allow cap electron commands (#4854)
1 parent 8a69ae0 commit 46da22f

File tree

1 file changed

+13
-2
lines changed
  • packages/@ionic/cli/src/commands/capacitor

1 file changed

+13
-2
lines changed

packages/@ionic/cli/src/commands/capacitor/base.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ export abstract class CapacitorCommand extends Command {
134134
}
135135
});
136136

137+
isCorePlatform(platform: string): boolean {
138+
const platforms = ['android', 'ios'];
139+
return platforms.includes(platform);
140+
}
141+
137142
async getInstalledPlatforms(): Promise<string[]> {
138143
const cli = await this.getCapacitorCLIConfig();
139144
const androidPlatformDirAbs = cli?.android.platformDirAbs ?? path.resolve(this.integration.root, 'android');
@@ -148,6 +153,10 @@ export abstract class CapacitorCommand extends Command {
148153
platforms.push('ios');
149154
}
150155

156+
if (await pathExists(path.resolve(this.integration.root, 'electron'))) {
157+
platforms.push('electron');
158+
}
159+
151160
return platforms;
152161
}
153162

@@ -297,8 +306,10 @@ export abstract class CapacitorCommand extends Command {
297306
}
298307

299308
if (semver.gte(version, '3.0.0-alpha.1')) {
300-
const [ manager, ...managerArgs ] = await pkgManagerArgs(this.env.config.get('npmClient'), { command: 'install', pkg: `@capacitor/${platform}@${version}`, saveDev: false });
301-
await this.env.shell.run(manager, managerArgs, { cwd: this.integration.root });
309+
if (this.isCorePlatform(platform)) {
310+
const [ manager, ...managerArgs ] = await pkgManagerArgs(this.env.config.get('npmClient'), { command: 'install', pkg: `@capacitor/${platform}@${version}`, saveDev: false });
311+
await this.env.shell.run(manager, managerArgs, { cwd: this.integration.root });
312+
}
302313
}
303314

304315
await this.runCapacitor(['add', platform]);

0 commit comments

Comments
 (0)