Skip to content

Commit

Permalink
hacks for running as a git pre-commit hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Jun 17, 2011
1 parent c11d54d commit abe67b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jslint
Expand Up @@ -3,4 +3,4 @@
# Follow symlinks to find the directory with the actual executable.
[ "`readlink -f $0`" != "$0" ] && exec `readlink -f $0` "$@"

nodejs "`dirname $0`/run-jslint.js" "$@"
exec node "`dirname $0`/run-jslint.js" "$@"
14 changes: 13 additions & 1 deletion run-jslint.js
Expand Up @@ -2,18 +2,29 @@
/*global require:false, process:false, sys:false */

(function (files) {
var sys = require('sys');

if (!files.length) {
sys.puts("Usage: jslint file.js");
process.exit(1);
}

files.forEach(function (file) {
if (file === "--ignore-no-files") {
return;
}
var input, success,
sys = require("sys"),
fs = require("fs"),
JSLINT = require('./fulljslint.js').JSLINT;

input = fs.readFileSync(file);
try {
input = fs.readFileSync(file);
} catch (e) {
sys.puts(e);
return;
}

if (!input) {
sys.puts("jslint: Couldn't open file '" + file + "'.");
return;
Expand Down Expand Up @@ -43,6 +54,7 @@
sys.puts('\t' + (e.evidence || '').replace(/^\s+|\s+$/, ""));
}
});
process.exit(2);
}
});
}(process.argv.slice(2)));

0 comments on commit abe67b2

Please sign in to comment.