Skip to content

Commit

Permalink
fix(cli): handle edit-config with merge mode on application object (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jan 13, 2020
1 parent e904eaa commit 9e56701
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cli/src/android/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ async function writeCordovaAndroidManifest(cordovaPlugins: Plugin[], config: Con
const manifestPath = join(pluginsFolder, 'src', 'main', 'AndroidManifest.xml');
let rootXMLEntries: Array<any> = [];
let applicationXMLEntries: Array<any> = [];
let applicationXMLAttributes: Array<any> = [];
cordovaPlugins.map(async p => {
const editConfig = getPlatformElement(p, platform, 'edit-config');
const configFile = getPlatformElement(p, platform, 'config-file');
Expand All @@ -219,7 +220,11 @@ async function writeCordovaAndroidManifest(cordovaPlugins: Plugin[], config: Con
const pathParts = getPathParts(configElement.$.parent || configElement.$.target);
if (pathParts.length > 1) {
if (pathParts.pop() === 'application') {
if (!applicationXMLEntries.includes(xmlElement) && !contains(applicationXMLEntries, xmlElement, k)) {
if (configElement.$.mode && configElement.$.mode === 'merge') {
Object.keys(e.$).map((ek: any) => {
applicationXMLAttributes.push(`${ek}="${e.$[ek]}"`);
});
} else if (!applicationXMLEntries.includes(xmlElement) && !contains(applicationXMLEntries, xmlElement, k)) {
applicationXMLEntries.push(xmlElement);
}
} else {
Expand All @@ -239,7 +244,7 @@ async function writeCordovaAndroidManifest(cordovaPlugins: Plugin[], config: Con
<manifest package="capacitor.android.plugins"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.amazon.com/apk/res/android">
<application>
<application ${applicationXMLAttributes.join('\n')}>
${applicationXMLEntries.join('\n')}
</application>
${rootXMLEntries.join('\n')}
Expand Down

0 comments on commit 9e56701

Please sign in to comment.