UNPKG

ember-codemod-pod-to-octane

Version:

Codemod to un-pod Ember apps, addons, and engines

39 lines (38 loc) 1.39 kB
import { findFiles, parseFilePath } from '@codemod-utils/files'; import { renamePodPath } from '../../../../../utils/files/index.js'; function getFileName(filePath) { const { name } = parseFilePath(filePath); return name; } /* Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli */ export function mapRoutes1(options) { const { projectRoot } = options; const podDir = 'tests/unit'; const filePathsForController = findFiles(`${podDir}/**/controller-test.{js,ts}`, { ignoreList: ['tests/unit/controllers/**'], projectRoot, }); const filePathsForRoute = findFiles(`${podDir}/**/route-test.{js,ts}`, { ignoreList: ['tests/unit/routes/**'], projectRoot, }); return [...filePathsForController, ...filePathsForRoute].map((oldFilePath) => { const fileName = getFileName(oldFilePath); const newFilePath = renamePodPath(oldFilePath, { podDir, replace: (dir) => { switch (fileName) { case 'controller-test': { return `tests/unit/controllers/${dir}-test`; } case 'route-test': { return `tests/unit/routes/${dir}-test`; } } }, }); return [oldFilePath, newFilePath]; }); }