Skip to content

Commit a6ef8a9

Browse files
author
Fatme
authored
Merge pull request #3634 from NativeScript/fatme/fix-double-ref
Touch app.gradle file only if __PACKAGE__ placeholder exists
2 parents 9c9cdcf + 9ff607c commit a6ef8a9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ export class ProjectTemplateErrors {
205205
export class Hooks {
206206
public static createProject = "createProject";
207207
}
208+
209+
export const PACKAGE_PLACEHOLDER_NAME = "__PACKAGE__";

lib/services/android-project-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
256256

257257
try {
258258
// will replace applicationId in app/App_Resources/Android/app.gradle if it has not been edited by the user
259-
shell.sed('-i', /__PACKAGE__/, projectData.projectId, projectData.appGradlePath);
259+
const appGradleContent = this.$fs.readText(projectData.appGradlePath);
260+
if (appGradleContent.indexOf(constants.PACKAGE_PLACEHOLDER_NAME) !== -1) {
261+
shell.sed('-i', new RegExp(constants.PACKAGE_PLACEHOLDER_NAME), projectData.projectId, projectData.appGradlePath);
262+
}
260263
} catch (e) {
261264
this.$logger.warn(`\n${e}.\nCheck if you're using an outdated template and update it.`);
262265
}

0 commit comments

Comments
 (0)