Skip to content

Commit

Permalink
flatten android plugins with native code when copying into main/src
Browse files Browse the repository at this point in the history
  • Loading branch information
petekanev committed May 31, 2017
1 parent b519ecf commit e27050a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
5 changes: 4 additions & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
if (this.$fs.exists(pluginPlatformsFolderPath)) {
this.$fs.ensureDirectoryExists(pluginConfigurationDirectoryPath);

let isScoped = pluginData.name.indexOf("@") === 0;
let flattenedDependencyName = isScoped ? pluginData.name.replace("/", "_") : pluginData.name;

// Copy all resources from plugin
let resourcesDestinationDirectoryPath = path.join(this.getPlatformData(projectData).projectRoot, "src", pluginData.name);
let resourcesDestinationDirectoryPath = path.join(this.getPlatformData(projectData).projectRoot, "src", flattenedDependencyName);
this.$fs.ensureDirectoryExists(resourcesDestinationDirectoryPath);
shell.cp("-Rf", path.join(pluginPlatformsFolderPath, "*"), resourcesDestinationDirectoryPath);

Expand Down
25 changes: 12 additions & 13 deletions lib/tools/node-modules/node-modules-dest-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ export class TnsModulesCopy {
}

private copyDependencyDir(dependency: IDependencyData): void {
if (dependency.depth === 0) {
let isScoped = dependency.name.indexOf("@") === 0;
let targetDir = this.outputRoot;

if (isScoped) {
targetDir = path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/")));
}
const targetPackageDir = path.join(this.outputRoot, dependency.name);

// check if dependency is scoped, and create a parent @scope directory to copy dependencies into
// shelljs otherwise complains during the copy step: 'cp: cannot create directory'
let isScoped = dependency.name.indexOf("@") === 0;

if (isScoped) {
shelljs.mkdir("-p", path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/"))));
}

shelljs.mkdir("-p", targetDir);
shelljs.cp("-Rf", dependency.directory, targetDir);
shelljs.cp("-Rf", dependency.directory, targetPackageDir);

// remove platform-specific files (processed separately by plugin services)
const targetPackageDir = path.join(isScoped ? this.outputRoot : targetDir, dependency.name);
shelljs.rm("-rf", path.join(targetPackageDir, "platforms"));
}
// remove platform-specific files (processed separately by plugin services)
shelljs.rm("-rf", path.join(targetPackageDir, "platforms"));
}
}

Expand Down

0 comments on commit e27050a

Please sign in to comment.