Skip to content

Commit e48d94e

Browse files
committed
Allowed passing newComponentStructure to Migrator class
1 parent b5b6c26 commit e48d94e

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

bin/ember-component-template-colocation-migrator

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ let options = {
1414
let parsed = nopt(options);
1515
let projectRoot = parsed['project-root'] || process.cwd();
1616

17-
let migrator = new Migrator({ projectRoot });
17+
let newComponentStructure = 'flat';
18+
19+
let migrator = new Migrator({
20+
projectRoot,
21+
newComponentStructure
22+
});
1823

1924
migrator.execute().then(function() {
2025
console.log('Codemod finished successfully!');

lib/migrator.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ const { moveFile, removeDirs } = require('./utils/file')
66

77
module.exports = class Migrator {
88
constructor(options) {
9-
const { projectRoot } = options;
9+
const { projectRoot, newComponentStructure } = options;
1010

1111
this.projectRoot = projectRoot;
12+
this.newComponentStructure = newComponentStructure;
1213
}
1314

1415
findClassicComponentTemplates() {
@@ -120,7 +121,9 @@ module.exports = class Migrator {
120121
templateFilePaths = this.skipTemplatesUsedAsLayoutName(templateFilePaths);
121122
templateFilePaths = this.skipTemplatesUsedAsPartial(templateFilePaths);
122123

123-
this.changeComponentStructureToFlat(templateFilePaths);
124+
if (this.newComponentStructure === 'flat') {
125+
this.changeComponentStructureToFlat(templateFilePaths);
126+
}
124127

125128
// Clean up
126129
await this.removeEmptyClassicComponentDirectories();

test/migrator-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ describe("Migrator", function() {
3838
fixturify.writeSync(tmpPath, input);
3939

4040
var migratorOptions = Object.assign(
41-
{ projectRoot: tmpPath },
41+
{
42+
projectRoot: tmpPath,
43+
newComponentStructure: 'flat'
44+
},
4245
migratorConfig
4346
);
4447

0 commit comments

Comments
 (0)