Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Don't prompt cordova preferences if non interactive #4680

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 38 additions & 35 deletions cli/src/cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from './plugin';
import type { Plugin } from './plugin';
import { resolveNode } from './util/node';
import { isInteractive } from './util/term';
import { buildXmlElement, parseXML, readXML, writeXML } from './util/xml';

/**
Expand Down Expand Up @@ -513,43 +514,45 @@ export async function getCordovaPreferences(config: Config): Promise<any> {
}
}
if (cordova.preferences && Object.keys(cordova.preferences).length > 0) {
const answers = await logPrompt(
`${c.strong(
`Cordova preferences can be automatically ported to ${c.strong(
config.app.extConfigName,
)}.`,
)}\n` +
`Keep in mind: Not all values can be automatically migrated from ${c.strong(
'config.xml',
)}. There may be more work to do.\n` +
`More info: ${c.strong(
'https://capacitorjs.com/docs/cordova/migrating-from-cordova-to-capacitor',
)}`,
{
type: 'confirm',
name: 'confirm',
message: `Migrate Cordova preferences from config.xml?`,
initial: true,
},
);
if (answers.confirm) {
if (config.app.extConfig?.cordova?.preferences) {
const answers = await prompts(
[
{
type: 'confirm',
name: 'confirm',
message: `${config.app.extConfigName} already contains Cordova preferences. Overwrite?`,
},
],
{ onCancel: () => process.exit(1) },
);
if (!answers.confirm) {
cordova = config.app.extConfig?.cordova;
if (isInteractive()) {
const answers = await logPrompt(
`${c.strong(
`Cordovaaa preferences can be automatically ported to ${c.strong(
config.app.extConfigName,
)}.`,
)}\n` +
`Keep in mind: Not all values can be automatically migrated from ${c.strong(
'config.xml',
)}. There may be more work to do.\n` +
`More info: ${c.strong(
'https://capacitorjs.com/docs/cordova/migrating-from-cordova-to-capacitor',
)}`,
{
type: 'confirm',
name: 'confirm',
message: `Migrate Cordova preferences from config.xml?`,
initial: true,
},
);
if (answers.confirm) {
if (config.app.extConfig?.cordova?.preferences) {
const answers = await prompts(
[
{
type: 'confirm',
name: 'confirm',
message: `${config.app.extConfigName} already contains Cordova preferences. Overwrite?`,
},
],
{ onCancel: () => process.exit(1) },
);
if (!answers.confirm) {
cordova = config.app.extConfig?.cordova;
}
}
} else {
cordova = config.app.extConfig?.cordova;
}
} else {
cordova = config.app.extConfig?.cordova;
}
} else {
cordova = config.app.extConfig?.cordova;
Expand Down