MCPcopy
hub / github.com/angular/angular / migrateFiles

Function migrateFiles

packages/localize/tools/src/migrate/index.ts:30–52  ·  view source on GitHub ↗
({
  rootPath,
  translationFilePaths,
  mappingFilePath,
  logger,
}: MigrateFilesOptions)

Source from the content-addressed store, hash-verified

28
29/** Migrates the legacy message IDs based on the passed in configuration. */
30export function migrateFiles({
31 rootPath,
32 translationFilePaths,
33 mappingFilePath,
34 logger,
35}: MigrateFilesOptions) {
36 const fs = getFileSystem();
37 const absoluteMappingPath = fs.resolve(rootPath, mappingFilePath);
38 const mapping = JSON.parse(fs.readFile(absoluteMappingPath)) as MigrationMapping;
39
40 if (Object.keys(mapping).length === 0) {
41 logger.warn(
42 `Mapping file at ${absoluteMappingPath} is empty. Either there are no messages ` +
43 `that need to be migrated, or the extraction step failed to find them.`,
44 );
45 } else {
46 translationFilePaths.forEach((path) => {
47 const absolutePath = fs.resolve(rootPath, path);
48 const sourceCode = fs.readFile(absolutePath);
49 fs.writeFile(absolutePath, migrateFile(sourceCode, mapping));
50 });
51 }
52}

Callers 2

main_spec.tsFile · 0.90
cli.tsFile · 0.90

Calls 9

migrateFileFunction · 0.90
getFileSystemFunction · 0.85
resolveMethod · 0.65
parseMethod · 0.65
readFileMethod · 0.65
keysMethod · 0.65
warnMethod · 0.65
writeFileMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…