ember-codemod-pod-to-octane
Version:
Codemod to un-pod Ember apps, addons, and engines
14 lines (13 loc) • 658 B
JavaScript
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');
});
}