UNPKG

ember-codemod-pod-to-octane

Version:
14 lines (13 loc) 658 B
import { readFileSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; export function updatePathsInAppFolder(filePathMap, options) { const { projectRoot } = options; filePathMap.forEach((newFilePath, oldFilePath) => { const newAbsolutePath = join(projectRoot, newFilePath); const file = readFileSync(newAbsolutePath, 'utf8'); const text = oldFilePath.replace(/^app\//, '').replace(/\.js$/, ''); const newText = newFilePath.replace(/^app\//, '').replace(/\.js$/, ''); const newFile = file.replace(new RegExp(text), newText); writeFileSync(newAbsolutePath, newFile, 'utf8'); }); }