|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | | -var sep = require('path').sep; |
4 | 3 | var chalk = require('chalk'); |
5 | | -var fs = require('fs'); |
6 | | -var file = require('file'); |
| 4 | +var filepaths = require('node-filepaths'); |
7 | 5 | var program = require('commander'); |
8 | 6 | var Detector = require('../lib/detector'); |
9 | 7 | var reporters = require('../lib/reporters'); |
@@ -32,35 +30,15 @@ if (!program.color) { |
32 | 30 | } |
33 | 31 |
|
34 | 32 | // Iterate over the given paths, and recurse if they're directories |
35 | | -var paths = []; |
36 | | -suppliedPaths.forEach(function(path) { |
37 | | - try { |
38 | | - if (fs.statSync(path).isFile()) { |
39 | | - return paths.push(path); |
40 | | - } |
41 | | - } catch(e) { |
42 | | - console.log('No such file or directory:', path); |
43 | | - process.exit(3); |
44 | | - } |
45 | | - |
46 | | - // Look for .js files, ignore node_modules, cleanup paths |
47 | | - file.walkSync(path, function(dirPath, dirs, files) { |
48 | | - files.forEach(function(file) { |
49 | | - if (file.slice(-3) !== '.js') return; |
50 | | - if (dirPath.indexOf('node_modules') > -1) return; |
51 | | - |
52 | | - if (dirPath.slice(-1) !== sep) { |
53 | | - dirPath += sep; |
54 | | - } |
55 | | - |
56 | | - if (dirPath.indexOf(sep) !== 0 && dirPath.indexOf('.') !== 0) { |
57 | | - dirPath = './' + dirPath; |
58 | | - } |
59 | | - |
60 | | - paths.push(dirPath + file); |
61 | | - }); |
| 33 | +try { |
| 34 | + var paths = filepaths.getSync(suppliedPaths, { |
| 35 | + suffix: '.js', |
| 36 | + ignore: 'node_modules' |
62 | 37 | }); |
63 | | -}); |
| 38 | +} catch(e) { |
| 39 | + console.log(e.message); |
| 40 | + process.exit(3); |
| 41 | +} |
64 | 42 |
|
65 | 43 | if (!paths.length) { |
66 | 44 | console.log('No .js files found in the list of paths'); |
|
0 commit comments