Skip to content

Commit 77fa904

Browse files
committed
fix(cordova): warn about missing cordova-res when adding platforms
If cordova-res isn't installed, print a warning message about how to install and what to do next. ref: #4026
1 parent 19edbf3 commit 77fa904

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/ionic/src/commands/cordova/platform.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as lodash from 'lodash';
33

44
import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandPreRun } from '../../definitions';
55
import { input } from '../../lib/color';
6-
import { SUPPORTED_PLATFORMS } from '../../lib/cordova-res';
6+
import { SUPPORTED_PLATFORMS, createCordovaResNotFoundMessage, findCordovaRes } from '../../lib/cordova-res';
77
import { FatalException } from '../../lib/errors';
88
import { runCommand } from '../../lib/executor';
99

@@ -104,7 +104,18 @@ Like running ${input('cordova platform')} directly, but adds default Ionic icons
104104

105105
if (action === 'add' && options['resources'] && SUPPORTED_PLATFORMS.includes(platformName)) {
106106
const args = ['cordova', 'resources', platformName, '--force'];
107-
await runCommand(runinfo, args);
107+
const p = await findCordovaRes();
108+
109+
if (p) {
110+
await runCommand(runinfo, args);
111+
} else {
112+
this.env.log.warn(await createCordovaResNotFoundMessage(this.env.config.get('npmClient')));
113+
this.env.log.warn(
114+
`Cannot generate resources without ${input('cordova-res')} installed.\n` +
115+
`Once installed, you can generate resources with the following command:\n\n` +
116+
input(['ionic', ...args].join(' '))
117+
);
118+
}
108119
}
109120
}
110121
}

0 commit comments

Comments
 (0)