Skip to content

Commit e7f7d93

Browse files
committed
flatten android plugins with native code when copying into main/src
1 parent b519ecf commit e7f7d93

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/services/android-project-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
361361
if (this.$fs.exists(pluginPlatformsFolderPath)) {
362362
this.$fs.ensureDirectoryExists(pluginConfigurationDirectoryPath);
363363

364+
let isScoped = pluginData.name.indexOf("@") === 0;
365+
let flattenedDependencyName = isScoped ? pluginData.name.replace("/", "_") : pluginData.name;
366+
364367
// Copy all resources from plugin
365-
let resourcesDestinationDirectoryPath = path.join(this.getPlatformData(projectData).projectRoot, "src", pluginData.name);
368+
let resourcesDestinationDirectoryPath = path.join(this.getPlatformData(projectData).projectRoot, "src", flattenedDependencyName);
366369
this.$fs.ensureDirectoryExists(resourcesDestinationDirectoryPath);
367370
shell.cp("-Rf", path.join(pluginPlatformsFolderPath, "*"), resourcesDestinationDirectoryPath);
368371

lib/tools/node-modules/node-modules-dest-copy.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@ export class TnsModulesCopy {
3636

3737
private copyDependencyDir(dependency: IDependencyData): void {
3838
if (dependency.depth === 0) {
39+
const targetPackageDir = path.join(this.outputRoot, dependency.name);
40+
41+
shelljs.mkdir("-p", targetPackageDir);
42+
3943
let isScoped = dependency.name.indexOf("@") === 0;
40-
let targetDir = this.outputRoot;
4144

4245
if (isScoped) {
43-
targetDir = path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/")));
46+
// copy module into tns_modules/@scope/module instead of tns_modules/module
47+
shelljs.cp("-Rf", dependency.directory, path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/"))));
48+
} else {
49+
shelljs.cp("-Rf", dependency.directory, this.outputRoot);
4450
}
4551

46-
shelljs.mkdir("-p", targetDir);
47-
shelljs.cp("-Rf", dependency.directory, targetDir);
48-
4952
// remove platform-specific files (processed separately by plugin services)
50-
const targetPackageDir = path.join(isScoped ? this.outputRoot : targetDir, dependency.name);
5153
shelljs.rm("-rf", path.join(targetPackageDir, "platforms"));
5254
}
5355
}

0 commit comments

Comments
 (0)