MCPcopy
hub / github.com/angular/angular / migrateFile

Function migrateFile

packages/localize/tools/src/migrate/migrate.ts:15–25  ·  view source on GitHub ↗
(sourceCode: string, mapping: MigrationMapping)

Source from the content-addressed store, hash-verified

13
14/** Migrates the legacy message IDs within a single file. */
15export function migrateFile(sourceCode: string, mapping: MigrationMapping) {
16 const legacyIds = Object.keys(mapping);
17
18 for (const legacyId of legacyIds) {
19 const canonicalId = mapping[legacyId];
20 const pattern = new RegExp(escapeRegExp(legacyId), 'g');
21 sourceCode = sourceCode.replace(pattern, canonicalId);
22 }
23
24 return sourceCode;
25}
26
27/** Escapes special regex characters in a string. */
28function escapeRegExp(str: string): string {

Callers 2

migrate_spec.tsFile · 0.90
migrateFilesFunction · 0.90

Calls 3

escapeRegExpFunction · 0.70
keysMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…