standard
Advanced tools
Comparing version 2.3.2 to 2.4.0
@@ -38,6 +38,7 @@ #!/usr/bin/env node | ||
standard({ | ||
bare: argv.bare, | ||
cwd: process.cwd(), | ||
bare: argv.bare, | ||
files: argv._, | ||
stdin: !process.stdin.isTTY, | ||
verbose: argv.verbose | ||
}) |
35
index.js
@@ -8,2 +8,3 @@ var cp = require('child_process') | ||
var split = require('split') | ||
var uniq = require('uniq') | ||
@@ -40,6 +41,7 @@ var JSCS = path.join(__dirname, 'node_modules', '.bin', 'jscs') | ||
* @param {string|Array.<String>} opts.ignore files to ignore | ||
* @param {boolean} opts.bare show raw linter output (for debugging) | ||
* @param {string} opts.cwd current working directory | ||
* @param {Array.<string>} files files to check | ||
* @param {boolean} opts.stdin check text from stdin instead of filesystem | ||
* @param {boolean} opts.verbose show error codes | ||
* @param {boolean} opts.bare show raw linter output (for debugging) | ||
* @param {boolean} opts.stdin check text from stdin instead of filesystem | ||
*/ | ||
@@ -77,2 +79,6 @@ module.exports = function standard (opts) { | ||
} else { | ||
var patterns = (Array.isArray(opts.files) && opts.files.length > 0) | ||
? opts.files | ||
: [ '**/*.js' ] | ||
// traverse filesystem | ||
@@ -85,6 +91,21 @@ if (opts.ignore) ignore = ignore.concat(opts.ignore) | ||
glob('**/*.js', { | ||
cwd: opts.cwd || process.cwd() | ||
}, function (err, files) { | ||
parallel(patterns.map(function (pattern) { | ||
return function (cb) { | ||
glob(pattern, { | ||
cwd: opts.cwd || process.cwd(), | ||
nodir: true | ||
}, cb) | ||
} | ||
}), function (err, results) { | ||
if (err) return error(err) | ||
// flatten nested arrays | ||
var files = results.reduce(function (files, result) { | ||
result.forEach(function (file) { | ||
files.push(file) | ||
}) | ||
return files | ||
}, []) | ||
// apply ignore patterns | ||
files = files.filter(function (file) { | ||
@@ -95,2 +116,6 @@ return !ignore.some(function (mm) { | ||
}) | ||
// de-dupe | ||
files = uniq(files) | ||
jscsArgs = jscsArgs.concat(files) | ||
@@ -97,0 +122,0 @@ eslintArgs = eslintArgs.concat(files) |
{ | ||
"name": "standard", | ||
"description": "JavaScript Standard Style", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"author": { | ||
@@ -24,3 +24,4 @@ "name": "Feross Aboukhadijeh", | ||
"run-parallel": "^1.0.0", | ||
"split": "^0.3.2" | ||
"split": "^0.3.2", | ||
"uniq": "^1.0.1" | ||
}, | ||
@@ -27,0 +28,0 @@ "devDependencies": { |
24865
330
9
+ Addeduniq@^1.0.1
+ Addeduniq@1.0.1(transitive)