Skip to content

Commit db60879

Browse files
committed
fix(info): show 'not available' when cordova is missing
fixes #3443
1 parent 2e56dd7 commit db60879

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

  • packages/@ionic/cli-utils/src/lib/integrations/cordova

packages/@ionic/cli-utils/src/lib/integrations/cordova/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Integration extends BaseIntegration {
3131

3232
const info: InfoItem[] = [
3333
{ group: 'cordova', key: 'cordova', flair: 'Cordova CLI', value: cordovaVersion || 'not installed' },
34-
{ group: 'cordova', key: 'Cordova Platforms', value: cordovaPlatforms || 'none' },
34+
{ group: 'cordova', key: 'Cordova Platforms', value: cordovaPlatforms },
3535
];
3636

3737
if (xcode) {
@@ -71,19 +71,24 @@ export class Integration extends BaseIntegration {
7171
return this.shell.cmdinfo('cordova', ['-v', '--no-telemetry']);
7272
}
7373

74-
async getCordovaPlatformVersions(): Promise<string | undefined> {
74+
async getCordovaPlatformVersions(): Promise<string> {
7575
try {
7676
const output = await this.shell.output('cordova', ['platform', 'ls', '--no-telemetry'], { showCommand: false });
77-
78-
return output
77+
const platforms = output
7978
.replace('Installed platforms:', '')
8079
.replace(/Available platforms[\s\S]+/, '')
8180
.split('\n')
8281
.map(l => l.trim())
83-
.filter(l => l && !l.startsWith('.'))
84-
.join(', ');
82+
.filter(l => l && !l.startsWith('.'));
83+
84+
if (platforms.length === 0) {
85+
return 'none';
86+
}
87+
88+
return platforms.join(', ');
8589
} catch (e) {
8690
debug('Error while getting Cordova platforms: %o', e);
91+
return 'not available';
8792
}
8893
}
8994

0 commit comments

Comments
 (0)