Skip to content

Commit 2176e8c

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

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
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

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ export class TnsModulesCopy {
3535
}
3636

3737
private copyDependencyDir(dependency: IDependencyData): void {
38-
if (dependency.depth === 0) {
39-
let isScoped = dependency.name.indexOf("@") === 0;
40-
let targetDir = this.outputRoot;
38+
const targetPackageDir = path.join(this.outputRoot, dependency.name);
4139

42-
if (isScoped) {
43-
targetDir = path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/")));
44-
}
40+
// check if dependency is scoped, and create a parent @scope directory to copy dependencies into
41+
// shelljs otherwise complains during the copy step: 'cp: cannot create directory'
42+
// let isScoped = dependency.name.indexOf("@") === 0;
4543

46-
shelljs.mkdir("-p", targetDir);
47-
shelljs.cp("-Rf", dependency.directory, targetDir);
44+
// if (isScoped) {
45+
// shelljs.mkdir("-p", path.join(this.outputRoot, dependency.name.substring(0, dependency.name.indexOf("/"))));
46+
// }
4847

49-
// remove platform-specific files (processed separately by plugin services)
50-
const targetPackageDir = path.join(isScoped ? this.outputRoot : targetDir, dependency.name);
51-
shelljs.rm("-rf", path.join(targetPackageDir, "platforms"));
52-
}
48+
shelljs.mkdir("-p", targetPackageDir);
49+
shelljs.cp("-Rf", dependency.directory, this.outputRoot);
50+
51+
// remove platform-specific files (processed separately by plugin services)
52+
shelljs.rm("-rf", path.join(targetPackageDir, "platforms"));
5353
}
5454
}
5555

0 commit comments

Comments
 (0)