Skip to content

Commit

Permalink
Allow specifying options via rhino command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mbulman committed Feb 19, 2011
1 parent afc94f2 commit 9991adf
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions env/rhino.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
load("jshint.js");

(function (args) {
var name = args[0], input;
var name = args[0],
optstr = args[1], // arg1=val1,arg2=val2,...
opts = {rhino: true},
input, optname, optval;

if (!name) {
print('Usage: jshint.js file.js');
quit(1);
}

if (optstr) {
optstr.split(',').forEach(function(arg) {
[optname,optval] = arg.split('=');
opts[optname] = optval;
});
}

input = readFile(name);

if (!input) {
print('jshint: Couldn\'t open file ' + name);
quit(1);
}

if (!JSHINT(input, { rhino: true })) {
if (!JSHINT(input, opts)) {
for (var i = 0, err; err = JSHINT.errors[i]; i++) {
print(err.reason + ' (line: ' + err.line + ', character: ' + err.character + ')');
print('> ' + (err.evidence || '').replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
Expand All @@ -27,4 +37,4 @@ load("jshint.js");
}

quit(0);
}(arguments));
}(arguments));

0 comments on commit 9991adf

Please sign in to comment.