From 4d151d3057908417088543d9ce45f1f972f95e41 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 11 Nov 2018 15:07:01 -0500 Subject: [PATCH] GH-539 fix destination path fallback (PR #542) Fallback to old path mapping if no Android Studio path mapping exists (with slight difference on 7.1.x branch) Co-authored-by: Christopher J. Brody Co-authored-by: Kyle Kirbatski --- bin/templates/cordova/lib/pluginHandlers.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index a3ebed0e..e78e3ee4 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -34,7 +34,7 @@ var handlers = { // a later plugins release. This is for legacy plugins to work with Cordova. if (options && options.android_studio === true) { - dest = studioPathRemap(obj); + dest = getInstallDestination(obj); } if (options && options.force) { @@ -47,7 +47,7 @@ var handlers = { var dest = path.join(obj.targetDir, path.basename(obj.src)); if (options && options.android_studio === true) { - dest = studioPathRemap(obj); + dest = getInstallDestination(obj); } // TODO: Add Koltin extension to uninstall, since they are handled like Java files @@ -317,6 +317,11 @@ function generateAttributeError (attribute, element, id) { return 'Required attribute "' + attribute + '" not specified in <' + element + '> element from plugin: ' + id; } +function getInstallDestination (obj) { + return studioPathRemap(obj) || + path.join(obj.targetDir, path.basename(obj.src)); +} + function studioPathRemap (obj) { // If a Java file is using the new directory structure, don't penalize it if (!obj.targetDir.includes('app/src/main')) {