Skip to content

Flatten scoped module when copying into android/src #2837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 9 additions & 7 deletions lib/tools/node-modules/node-modules-dest-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ export class TnsModulesCopy {

private copyDependencyDir(dependency: IDependencyData): void {
if (dependency.depth === 0) {
const targetPackageDir = path.join(this.outputRoot, dependency.name);

shelljs.mkdir("-p", targetPackageDir);

let isScoped = dependency.name.indexOf("@") === 0;
let targetDir = this.outputRoot;

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

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

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