ember-codemod-pod-to-octane
Version:
Codemod to un-pod Ember apps, addons, and engines
37 lines (36 loc) • 1.4 kB
JavaScript
import { findFiles } from '@codemod-utils/files';
import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
/*
Case 2: Passed the --pod flag to Ember CLI
*/
export function mapRoutes2(options) {
const { podPath, projectRoot } = options;
const podDirForController = normalizedJoin('tests/unit', podPath, 'controllers');
const filePathsForController = findFiles(`${podDirForController}/**/controller-test.{js,ts}`, {
projectRoot,
});
const podDirForRoute = normalizedJoin('tests/unit', podPath, 'routes');
const filePathsForRoute = findFiles(`${podDirForRoute}/**/route-test.{js,ts}`, {
projectRoot,
});
return [
...filePathsForController.map((oldFilePath) => {
const newFilePath = renamePodPath(oldFilePath, {
podDir: podDirForController,
replace: (dir) => {
return `tests/unit/controllers/${dir}-test`;
},
});
return [oldFilePath, newFilePath];
}),
...filePathsForRoute.map((oldFilePath) => {
const newFilePath = renamePodPath(oldFilePath, {
podDir: podDirForRoute,
replace: (dir) => {
return `tests/unit/routes/${dir}-test`;
},
});
return [oldFilePath, newFilePath];
}),
];
}