Skip to content

Commit 7ec24c0

Browse files
authored
fix(capacitor): Error if no emulators or devices are found on run (#4931)
1 parent 9badbe7 commit 7ec24c0

File tree

1 file changed

+10
-6
lines changed
  • packages/@ionic/cli/src/commands/capacitor

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,16 @@ For Android and iOS, you can setup Remote Debugging on your device with browser
205205
);
206206
}
207207
} else {
208-
options['target'] = await this.env.prompt({
209-
type: 'list',
210-
name: 'target',
211-
message: 'Which device would you like to target?',
212-
choices: targets.map(t => ({ name: `${t.name} (${t.id})`, value: t.id })),
213-
});
208+
if (targets.length > 0) {
209+
options['target'] = await this.env.prompt({
210+
type: 'list',
211+
name: 'target',
212+
message: 'Which device would you like to target?',
213+
choices: targets.map(t => ({ name: `${t.name} (${t.id})`, value: t.id })),
214+
});
215+
} else {
216+
throw new FatalException(`No devices or emulators found`);
217+
}
214218

215219
if (!inputs[0]) {
216220
throw new FatalException(`The ${input('platform')} argument is required.`);

0 commit comments

Comments
 (0)