@@ -67,27 +67,34 @@ function runEndpointGen(name, opt={}) {
6767 } ) ;
6868}
6969
70- let eslintCmd = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/eslint' ) ;
71- function testFile ( command , _path ) {
72- _path = path . normalize ( _path ) ;
73- return fs . accessAsync ( _path , fs . R_OK ) . then ( ( ) => {
74- return runCmd ( `${ command } ${ _path } ` ) ;
75- } ) ;
70+ const ESLINT_CMD = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/eslint' ) ;
71+
72+ /**
73+ * @param {string[] } files
74+ * @param {string } [flags]
75+ */
76+ function eslintFiles ( files , flags = '' ) {
77+ return runCmd ( `${ ESLINT_CMD } ${ flags } ${ files . join ( ' ' ) } ` ) ;
7678}
7779
7880function eslintDir ( dir , name , folder ) {
7981 if ( ! folder ) folder = name ;
8082 let endpointDir = path . join ( dir , 'server/api' , folder ) ;
83+ let files = fs . readdirAsync ( endpointDir ) ;
8184
82- let regFiles = fs . readdirAsync ( endpointDir )
85+ let regFiles = files
8386 . then ( files => files . filter ( file => minimatch ( file , '**/!(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
84- . map ( file => testFile ( eslintCmd , path . join ( './server/api/' , folder , file ) ) ) ;
87+ . then ( files => files . map ( file => path . join ( './server/api/' , folder , file ) ) ) ;
8588
86- let specFiles = fs . readdirAsync ( endpointDir )
89+ let specFiles = files
8790 . then ( files => files . filter ( file => minimatch ( file , '**/+(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
88- . map ( file => testFile ( `${ eslintCmd } --env node,es6,mocha --global sinon,expect` , path . join ( './server/api/' , folder , file ) ) ) ;
91+ . then ( files => files . map ( file => path . join ( './server/api/' , folder , file ) ) ) ;
92+
93+ let regLint = regFiles . then ( files => eslintFiles ( files ) ) ;
94+
95+ let specLint = specFiles . then ( files => eslintFiles ( files , '--env node,es6,mocha --global sinon,expect' ) ) ;
8996
90- return Promise . all ( [ regFiles , specFiles ] ) ;
97+ return Promise . all ( [ regLint , specLint ] ) ;
9198}
9299
93100var config ;
0 commit comments