Skip to content

Commit 3c71296

Browse files
Merge pull request #227 from nimblehq/feature/207-rename-app-name-in-strings-xml
[#207] Rename app name in strings.xml
2 parents 7249d31 + 4490c20 commit 3c71296

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

scripts/new_project.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ object NewProject {
66
private const val DOT_SEPARATOR = "."
77
private const val KEY_APP_NAME = "app-name"
88
private const val KEY_PACKAGE_NAME = "package-name"
9+
private const val TEMPLATE_APP_NAME = "Coroutine Template"
910
private const val TEMPLATE_APPLICATION_CLASS_NAME = "CoroutineTemplateApplication"
1011
private const val TEMPLATE_FOLDER_NAME = "CoroutineTemplate"
1112
private const val TEMPLATE_PACKAGE_NAME = "co.nimblehq.coroutine"
@@ -38,6 +39,7 @@ object NewProject {
3839
renamePackageNameFolders()
3940
renamePackageNameWithinFiles()
4041
renameApplicationClass()
42+
renameAppName()
4143
buildProjectAndRunTests()
4244
}
4345

@@ -194,6 +196,20 @@ object NewProject {
194196
}
195197
}
196198

199+
private fun renameAppName() {
200+
showMessage("=> 🔎 Renaming app name...")
201+
File(projectPath)
202+
?.walk()
203+
.filter { it.name == "strings.xml" }
204+
.forEach { filePath ->
205+
rename(
206+
sourcePath = filePath.toString(),
207+
oldValue = TEMPLATE_APP_NAME,
208+
newValue = appName
209+
)
210+
}
211+
}
212+
197213
private fun rename(sourcePath: String, oldValue: String, newValue: String) {
198214
val sourceFile = File(sourcePath)
199215
var sourceText = sourceFile.readText()

0 commit comments

Comments
 (0)