@@ -0,0 +1,68 @@
1+#! /usr/bin/env node
2+/*jshint node:true, curly:true, onevar:true, maxlen:80 */
3+
4+var jshint = require('./jshint.js').JSHINT,
5+ fs = require('fs'),
6+ args = process.argv.slice(2),
7+ paths = [],
8+ options = {},
9+ files = {},
10+ hasProp = Object.prototype.hasOwnProperty,
11+ keyValuePair;
12+
13+args.forEach(function (arg) {
14+ if (arg.indexOf('/') !== -1) {
15+ /* path to js file */
16+ paths.push(arg);
17+ } else {
18+ /* jshint option */
19+ keyValuePair = arg.split(':');
20+ options[keyValuePair[0]] = keyValuePair[1];
21+ }
22+});
23+
24+function reportErrors (errors) {
25+ 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+ });
32+}
33+
34+function parseFiles() {
35+ var prop;
36+
37+ for (prop in files) {
38+ if (hasProp.call(files, prop)) {
39+ console.log("\n\nChecking "+ prop);
40+
41+ if (jshint(files[prop], options)) {
42+ console.log("Hooray, no lint!\n\n");
43+ } else {
44+ console.log("Error(s): \n");
45+ reportErrors(jshint.errors);
46+ }
47+ }
48+ }
49+}
50+
51+(function readAll () {
52+ var path;
53+
54+ if (paths.length > 0) {
55+ path = paths.shift();
56+ fs.readFile(path, 'utf8', function (err, out) {
57+ if (err) {
58+ throw err;
59+ }
60+
61+ files[path] = out;
62+
63+ readAll();
64+ });
65+ } else {
66+ parseFiles();
67+ }
68+}) ();