build-jshint
Advanced tools
Comparing version 0.0.1 to 0.0.2
19
index.js
@@ -36,5 +36,7 @@ var JSHINT = require('jshint').JSHINT, | ||
}); | ||
callback(null, true); | ||
} else { | ||
callback(null, false); | ||
} | ||
callback(); | ||
}); | ||
@@ -59,4 +61,10 @@ } | ||
var hasError = false; | ||
function processFile(file, callback) { | ||
hintFile(file, options, callback); | ||
hintFile(file, options, function(err, lintError) { | ||
if (err) { return callback(err); } | ||
hasError = hasError || lintError; | ||
callback(); | ||
}); | ||
} | ||
@@ -71,5 +79,8 @@ | ||
async.forEach(paths, processGlob, callback); | ||
async.forEach(paths, processGlob, function(err) { | ||
if (err) { return callback(err); } | ||
callback(null, hasError); | ||
}); | ||
} | ||
module.exports = buildJSHint; |
{ | ||
"name": "build-jshint", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Helper for running JSHint on files and directories", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
"minimatch": "~0.2.11", | ||
"async": "~0.2.5", | ||
"async": "~0.2.6", | ||
"glob": "~3.1" | ||
@@ -23,0 +23,0 @@ }, |
build-jshint | ||
============ | ||
[![Build Status](https://travis-ci.org/conradz/build-jshint.png)](https://travis-ci.org/conradz/build-jshint) | ||
Helper for running [JSHint](http://jshint.com) on JS files as part of a build | ||
@@ -14,4 +16,5 @@ step from a Node.JS script. | ||
// Errors will be logged to the console | ||
buildJSHint('src/**/*.js', function(err) { | ||
buildJSHint('src/**/*.js', function(err, hasError) { | ||
// `err` is a fatal error, *not* a JSHint error | ||
// `hasError` indicates if any of the files had a JSHint error | ||
}); | ||
@@ -44,3 +47,5 @@ | ||
buildJSHint(['src/file.js', 'src/scripts/*.js'], opts, function(err) { | ||
var files = ['src/file.js', 'src/scripts/*.js']; | ||
buildJSHint(files, opts, function(err, hasError) { | ||
// ... | ||
@@ -66,3 +71,5 @@ }); | ||
a fatal error occurred (such as error reading a file; JSHint errors are *not* | ||
included), it will be passed to the callback as the first argument. | ||
included), it will be passed to the callback as the first argument. The second | ||
arguments will be a boolean indicated whether a JSHint error was encountered in | ||
any of the files. | ||
@@ -69,0 +76,0 @@ License |
@@ -16,4 +16,5 @@ var buildJSHint = require('../index'), | ||
buildJSHint(file, opts, function(err) { | ||
buildJSHint(file, opts, function(err, hasError) { | ||
expect(err).to.not.exist; | ||
expect(hasError).to.be.true; | ||
expect(errors).to.have.length(1); | ||
@@ -32,4 +33,5 @@ done(); | ||
buildJSHint(filesDir, opts, function(err) { | ||
buildJSHint(filesDir, opts, function(err, hasError) { | ||
expect(err).to.not.exist; | ||
expect(hasError).to.be.false; | ||
expect(errors).to.be.empty; | ||
@@ -48,4 +50,5 @@ done(); | ||
var file = path.join(__dirname, 'files/error_global.js'); | ||
buildJSHint(file, opts, function(err) { | ||
buildJSHint(file, opts, function(err, hasError) { | ||
expect(err).to.not.exist; | ||
expect(hasError).to.be.true; | ||
expect(errors).to.have.length(1); | ||
@@ -65,4 +68,5 @@ done(); | ||
var file = path.join(__dirname, 'files/error_global.js'); | ||
buildJSHint(file, opts, function(err) { | ||
buildJSHint(file, opts, function(err, hasError) { | ||
expect(err).to.not.exist; | ||
expect(hasError).to.be.false; | ||
expect(errors).to.be.empty; | ||
@@ -69,0 +73,0 @@ done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9662
11
183
77
Updatedasync@~0.2.6