Skip to content

Commit

Permalink
fix(prepare): check config and platforms dir for platform state
Browse files Browse the repository at this point in the history
For freshly cloned projects that have platforms specified in config but
have not yet added them, `ionic cordova prepare` may not work as
expected.

This also fixes a bug in `ionic repair` where the warning was appearing
after `platforms/` was being deleted.

Fixes #3912
  • Loading branch information
imhoffd committed Mar 20, 2019
1 parent d0bc021 commit d9e1ced
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/ionic/src/commands/cordova/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ You may wish to use ${chalk.green('ionic cordova prepare')} if you run your proj
}

async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
const { loadConfigXml } = await import('../../lib/integrations/cordova/config');
const { getPlatforms } = await import('../../lib/integrations/cordova/project');
const [ platform ] = inputs;

Expand All @@ -77,9 +78,11 @@ You may wish to use ${chalk.green('ionic cordova prepare')} if you run your proj
),
});
} else {
const conf = await loadConfigXml(this.integration);
const platforms = await getPlatforms(this.integration.root);
const engines = conf.getPlatformEngines();

if (platforms.length === 0) {
if (engines.length === 0 && platforms.length === 0) {
this.env.log.warn(
`No platforms added to this project. Cannot prepare native platforms without any installed.\n` +
`Run ${chalk.green('ionic cordova platform add <platform>')} to add native platforms.`
Expand Down

0 comments on commit d9e1ced

Please sign in to comment.