Skip to content

Commit 840a89c

Browse files
committed
Refactored migrator by adding a better separation of concerns between removeEmptyClassicComponentDirectories and execute
1 parent e264611 commit 840a89c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/migrator.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,24 @@ module.exports = class Migrator {
101101
});
102102
}
103103

104-
async removeEmptyClassicComponentDirectories(removeOnlyEmptyDirectories) {
104+
async removeEmptyClassicComponentDirectories() {
105105
const templateFolderPath = path.join(this.projectRoot, 'app/templates/components');
106+
107+
const classFilePaths = this.findClassicComponentClasses();
108+
const templatesWithLayoutName = getLayoutNameTemplates(classFilePaths);
109+
const removeOnlyEmptyDirectories = Boolean(templatesWithLayoutName.length);
106110

107111
await removeDirs(templateFolderPath, removeOnlyEmptyDirectories);
108112
}
109113

110114
async execute() {
111115
let templateFilePaths = this.findClassicComponentTemplates();
112-
let classFilePaths = this.findClassicComponentClasses();
113-
114116
templateFilePaths = this.skipTemplatesUsedAsLayoutName(templateFilePaths);
115117
templateFilePaths = this.skipTemplatesUsedAsPartial(templateFilePaths);
116118

117119
this.changeComponentStructureToFlat(templateFilePaths);
118120

119-
const templatesWithLayoutName = getLayoutNameTemplates(classFilePaths);
120-
const removeOnlyEmptyDirectories = Boolean(templatesWithLayoutName.length);
121-
await this.removeEmptyClassicComponentDirectories(removeOnlyEmptyDirectories);
121+
// Clean up
122+
await this.removeEmptyClassicComponentDirectories();
122123
}
123124
}

0 commit comments

Comments
 (0)