ember-codemod-pod-to-octane
Version:
Codemod to un-pod Ember apps, addons, and engines
14 lines (13 loc) • 640 B
JavaScript
import { readFileSync, writeFileSync } from 'node:fs';
import { join, relative, sep } from 'node:path';
function getReexportPath(filePath) {
return relative('app', filePath).replace(/\.js$/, '').replaceAll(sep, '/');
}
export function updatePathsInAppFolder(filePathMap, options) {
const { projectRoot } = options;
filePathMap.forEach((newFilePath, oldFilePath) => {
const oldFile = readFileSync(join(projectRoot, newFilePath), 'utf8');
const newFile = oldFile.replace(getReexportPath(oldFilePath), getReexportPath(newFilePath));
writeFileSync(join(projectRoot, newFilePath), newFile, 'utf8');
});
}