@@ -3,6 +3,7 @@
33
44 var jshint = require('./jshint/jshint.js').JSHINT,
55 fs = require('fs'),
6+ path = require('path'),
67 args = process.argv.slice(2),
78 paths = [],
89 options = {},
@@ -21,14 +22,19 @@ args.forEach(function (arg) {
2122 }
2223 });
2324
24-function reportErrors (errors) {
25+function reportErrors (file, errors) {
26+ var str = "";
27+
28+ file = path.basename(file);
29+
2530 errors.forEach(function (err) {
26- console.log(
27- err.reason,
28- "\nline: "+ err.line +" char: "+ err.character,
29- "\n"+ err.evidence +"\n\n"
30- );
31+ /* Same error reporting syntax as @brentlintner's
32+ so that it works with 3rd party plugins (vim/emacs?) */
33+ str += file + ': line '+ err.line + ', col ' + err.character +
34+ ', ' + err.reason + '\n';
3135 });
36+
37+ console.log(str +"\n"+ errors.length + ' error(s)');
3238 }
3339
3440 function parseFiles() {
@@ -36,29 +42,28 @@ function parseFiles() {
3642
3743 for (prop in files) {
3844 if (hasProp.call(files, prop)) {
39- console.log("\n\nChecking "+ prop);
40-
4145 if (jshint(files[prop], options)) {
42- console.log("Hooray, no lint!\n\n");
46+ console.log("Hooray, no lint!");
47+ process.exit(0);
4348 } else {
44- console.log("Error(s): \n");
45- reportErrors(jshint.errors);
49+ reportErrors(prop, jshint.errors);
50+ process.exit(1);
4651 }
4752 }
4853 }
4954 }
5055
5156 (function readAll () {
52- var path;
57+ var filepath;
5358
5459 if (paths.length > 0) {
55- path = paths.shift();
56- fs.readFile(path, 'utf8', function (err, out) {
57- if (err) {
60+ filepath = paths.shift();
61+ fs.readFile(filepath, 'utf8', function (err, out) {
62+ if (err)
5863 throw err;
59- }
64+
6065
61- files[path] = out;
66+ files[filepath] = out;
6267
6368 readAll();
6469 });