Skip to content

Touch app.gradle file only if __PACKAGE__ placeholder exists #3634

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 1 commit into from
May 29, 2018
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
2 changes: 2 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,5 @@ export class ProjectTemplateErrors {
export class Hooks {
public static createProject = "createProject";
}

export const PACKAGE_PLACEHOLDER_NAME = "__PACKAGE__";
5 changes: 4 additions & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject

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