diff --git a/src/utils/create-app-task-run-init-script.ts b/src/utils/create-app-task-run-init-script.ts index 7ee89ae2..7121b511 100644 --- a/src/utils/create-app-task-run-init-script.ts +++ b/src/utils/create-app-task-run-init-script.ts @@ -81,7 +81,7 @@ async function initRename(args: GetArgsResult, init: InitScript, verbose: boolea console.error(`init-script.rename: target does not exist ${targetPath}`) continue } - await searchAndReplace(join(args.targetDirectory, path), fromNames, toNames, args.dryRun) + await searchAndReplace(join(args.targetDirectory, path), fromNames, toNames, args.dryRun, args.verbose) } } } diff --git a/src/utils/search-and-replace.ts b/src/utils/search-and-replace.ts index 8ff56413..1a0843d7 100644 --- a/src/utils/search-and-replace.ts +++ b/src/utils/search-and-replace.ts @@ -20,6 +20,10 @@ export async function searchAndReplace( let newContent = content for (const [i, fromString] of fromStrings.entries()) { + if (newContent.includes(fromString)) { + console.log(`searchAndReplace: processFile: Skipping ${filePath} because it includes ${fromString}`) + continue + } const regex = new RegExp(fromString, 'g') newContent = newContent.replace(regex, toStrings[i]) // Make sure we maintain the possible newline at the end of the file @@ -96,6 +100,12 @@ export async function searchAndReplace( let newPath = oldPath for (const [i, fromString] of fromStrings.entries()) { + if (newPath.includes(fromString)) { + console.log( + `searchAndReplace: renamePaths: Skipping ${oldPath} => ${newPath} because it includes ${fromString}`, + ) + continue + } newPath = newPath.replace(new RegExp(fromString, 'g'), toStrings[i]) }