@@ -113,6 +113,20 @@ function jshint(_path, opt={}) {
113113 return runCmd ( cmd ) ;
114114 } ) ;
115115}
116+
117+ function jshintDir ( dir , name , folder ) {
118+ if ( ! folder ) folder = name ;
119+ let endpointDir = path . join ( dir , 'server/api' , folder ) ;
120+
121+ let regFiles = fs . readdirAsync ( endpointDir )
122+ . then ( files => files . filter ( file => minimatch ( file , '**/!(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
123+ . map ( file => jshint ( path . join ( './server/api/' , folder , file ) ) ) ;
124+
125+ let specFiles = fs . readdirAsync ( endpointDir )
126+ . then ( files => files . filter ( file => minimatch ( file , '**/+(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
127+ . map ( file => jshint ( path . join ( './server/api/' , folder , file ) , { config : 'server/.jshintrc-spec' } ) ) ;
128+
129+ return Promise . all ( [ regFiles , specFiles ] ) ;
116130}
117131
118132var config ;
@@ -154,16 +168,7 @@ describe('angular-fullstack:endpoint', function() {
154168 it ( 'should pass jscs' ) ;
155169
156170 it ( 'should pass lint' , function ( ) {
157- let endpointDir = path . join ( dir , 'server/api/foo/' ) ;
158- let regFiles = fs . readdirAsync ( endpointDir )
159- . then ( files => files . filter ( file => minimatch ( file , '**/!(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
160- . map ( file => jshint ( `./server/api/foo/${ file } ` ) ) ;
161-
162- let specFiles = fs . readdirAsync ( endpointDir )
163- . then ( files => files . filter ( file => minimatch ( file , '**/+(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
164- . map ( file => jshint ( `./server/api/food/${ file } ` , { config : 'server/.jshintrc-spec' } ) ) ;
165-
166- return Promise . all ( [ regFiles , specFiles ] ) . should . be . fulfilled ( ) ;
171+ return jshintDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
167172 } ) ;
168173 } ) ;
169174
0 commit comments