@@ -12,19 +12,47 @@ module.exports = {
12
12
13
13
availableOptions : [ ] ,
14
14
15
- run ( ) {
15
+ appRoot ( ) {
16
+ let project = this . project ;
17
+
18
+ if ( project . isEmberCLIAddon ( ) ) {
19
+ return 'addon' ;
20
+ } else if ( project . isModuleUnification ( ) ) {
21
+ return 'src' ;
22
+ } else {
23
+ return 'app' ;
24
+ }
25
+ } ,
26
+
27
+ _scanForHbsFiles ( dir ) {
28
+ return walkSync ( dir , { globs : [ '**/*.hbs' ] } ) ;
29
+ } ,
30
+
31
+ getTemplateFiles ( ) {
16
32
let project = this . project ;
17
- let modulePrefix = project . config ( ) . modulePrefix ;
33
+ let appRoot = this . appRoot ( ) ;
34
+
35
+ if ( project . isEmberCLIAddon ( ) ) {
36
+ let files = this . _scanForHbsFiles ( appRoot ) ;
37
+ let moreFiles = this . _scanForHbsFiles ( 'tests/dummy/app' ) ;
38
+
39
+ return files . concat ( moreFiles ) ;
40
+ } else if ( project . isModuleUnification ( ) ) {
41
+ return this . _scanForHbsFiles ( appRoot ) ;
42
+ } else {
43
+ return this . _scanForHbsFiles ( appRoot ) ;
44
+ }
45
+ } ,
46
+
47
+ run ( ) {
48
+ let appRoot = this . appRoot ( ) ;
49
+ let modulePrefix = this . project . config ( ) . modulePrefix ;
18
50
let linter = new Linter ( ) ;
19
51
let templatesWithErrors = [ ] ;
20
-
21
- let templateFiles = walkSync ( 'app' ) . filter ( file => {
22
- // remove any non-hbs files
23
- return path . extname ( file ) === '.hbs' ;
24
- } ) ;
52
+ let templateFiles = this . getTemplateFiles ( ) ;
25
53
26
54
templateFiles . forEach ( file => {
27
- let filePath = path . join ( 'app' , file ) ;
55
+ let filePath = path . join ( appRoot , file ) ;
28
56
let contents = fs . readFileSync ( filePath , { encoding : 'utf8' } ) ;
29
57
let moduleId = path . join ( modulePrefix , file ) . slice ( 0 , - 4 ) ;
30
58
0 commit comments