Skip to content

Commit 33f13b4

Browse files
authored
Merge pull request #220 from solana-foundation/fix/init-script-rename-dedup
fix: remove buggy deduplication in init-script-rename
2 parents f4f9b7c + 1f73c77 commit 33f13b4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-solana-dapp": patch
3+
---
4+
5+
Fix init script rename failing with mismatched array lengths. The deduplication logic was breaking the 1:1 correspondence between from and to arrays.

src/utils/init-script-rename.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,16 @@ export async function initScriptRename(args: GetArgsResult, rename?: InitScriptR
4343
const fromNames = namesValues(from)
4444
const toNames = namesValues(to)
4545

46-
// Deduplicate the arrays to prevent multiple replacements of the same pattern
47-
const uniqueFromNames = [...new Set(fromNames)]
48-
const uniqueToNames = [...new Set(toNames)]
49-
5046
for (const path of rename[from].paths) {
5147
const targetPath = join(args.targetDirectory, path)
5248
if (!(await ensureTargetPath(targetPath))) {
5349
log.error(`${tag}: target does not exist ${targetPath}`)
5450
continue
5551
}
5652
if (args.verbose) {
57-
log.warn(`${tag}: ${targetPath} -> ${uniqueFromNames.join('|')} -> ${uniqueToNames.join('|')}`)
53+
log.warn(`${tag}: ${targetPath} -> ${fromNames.join('|')} -> ${toNames.join('|')}`)
5854
}
59-
await searchAndReplace(targetPath, uniqueFromNames, uniqueToNames, args.dryRun, args.verbose)
55+
await searchAndReplace(targetPath, fromNames, toNames, args.dryRun, args.verbose)
6056
}
6157
}
6258

0 commit comments

Comments
 (0)