Skip to content

Commit

Permalink
Cleanup getInstallDestination in pluginHandlers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Nov 14, 2018
1 parent bbb3913 commit 21f8473
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bin/templates/cordova/lib/pluginHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,17 @@ function generateAttributeError (attribute, element, id) {
}

function getInstallDestination (obj) {
return studioPathRemap(obj) ||
path.join(obj.targetDir, path.basename(obj.src));
}

function studioPathRemap (obj) {
// If any source file is using the app new directory structure,
// don't penalize it
if (!obj.targetDir.includes('app')) {
if (obj.src.endsWith('.java')) {
return path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src));
} else {
// For all other files, add 'app/src/main' to the targetDir if it didn't have it already
return path.join('app/src/main', obj.targetDir, path.basename(obj.src));
}
var APP_MAIN_PREFIX = 'app/src/main';

if (obj.targetDir.includes('app')) {
// If any source file is using the app new directory structure,
// don't penalize it
return path.join(obj.targetDir, path.basename(obj.src));
} else if (obj.src.endsWith('.java')) {
return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src));
} else {
// For all other files, add 'app/src/main' to the targetDir if it didn't have it already
return path.join(APP_MAIN_PREFIX, obj.targetDir, path.basename(obj.src));
}

}

0 comments on commit 21f8473

Please sign in to comment.