UNPKG

ember-codemod-pod-to-octane

Version:

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

37 lines (36 loc) 1.32 kB
import { findFiles } from '@codemod-utils/files'; import { renamePodPath } from '../../../../../utils/files/index.js'; /* Case 2: Passed the --pod flag to Ember CLI */ export function mapRoutes2(options) { const { projectRoot } = options; const podDirForController = 'tests/unit/controllers'; const filePathsForController = findFiles(`${podDirForController}/**/controller-test.{js,ts}`, { projectRoot, }); const podDirForRoute = 'tests/unit/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]; }), ]; }