From 244a7109b3773bde5427d3c252d1bc75f472ff20 Mon Sep 17 00:00:00 2001 From: James Herdman Date: Wed, 12 Sep 2018 23:03:24 -0400 Subject: [PATCH] Support Many Kinds of Projects Resolves #381 --- lib/commands/print-failing.js | 42 +++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/commands/print-failing.js b/lib/commands/print-failing.js index 4cc4b3d5..f525972a 100644 --- a/lib/commands/print-failing.js +++ b/lib/commands/print-failing.js @@ -12,19 +12,47 @@ module.exports = { availableOptions: [], - run() { + appRoot() { + let project = this.project; + let appRoot; + + if (project.isEmberCLIAddon()) { + return 'addon'; + } else if (project.isModuleUnification()) { + return 'src'; + } else { + return 'app'; + } + }, + + _scanForHbsFiles(dir) { + return walkSync(dir, { globs: ['**/*.hbs'] }); + }, + + getTemplateFiles() { let project = this.project; + let appRoot = this.appRoot(); + + if (project.isEmberCLIAddon()) { + let files = this._scanForHbsFiles(appRoot); + let moreFiles = this._scanForHbsFiles('tests/dummy/app'); + + return files.concat(moreFiles); + } else if (project.isModuleUnification()) { + return this._scanForHbsFiles(appRoot); + } else { + return this._scanForHbsFiles(appRoot); + } + }, + + run() { + let appRoot = this.appRoot(); let modulePrefix = project.config().modulePrefix; let linter = new Linter(); let templatesWithErrors = []; - let templateFiles = walkSync('app').filter(file => { - // remove any non-hbs files - return path.extname(file) === '.hbs'; - }); - templateFiles.forEach(file => { - let filePath = path.join('app', file); + let filePath = path.join(appRoot, file); let contents = fs.readFileSync(filePath, { encoding: 'utf8' }); let moduleId = path.join(modulePrefix, file).slice(0, -4);