@@ -67,27 +67,34 @@ function runEndpointGen(name, opt={}) { |
67 | 67 | }); |
68 | 68 | } |
69 | 69 |
|
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(' ')}`); |
76 | 78 | } |
77 | 79 |
|
78 | 80 | function eslintDir(dir, name, folder) { |
79 | 81 | if(!folder) folder = name; |
80 | 82 | let endpointDir = path.join(dir, 'server/api', folder); |
| 83 | + let files = fs.readdirAsync(endpointDir); |
81 | 84 |
|
82 | | - let regFiles = fs.readdirAsync(endpointDir) |
| 85 | + let regFiles = files |
83 | 86 | .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))); |
85 | 88 |
|
86 | | - let specFiles = fs.readdirAsync(endpointDir) |
| 89 | + let specFiles = files |
87 | 90 | .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')); |
89 | 96 |
|
90 | | - return Promise.all([regFiles, specFiles]); |
| 97 | + return Promise.all([regLint, specLint]); |
91 | 98 | } |
92 | 99 |
|
93 | 100 | var config; |
|