Skip to content

Commit

Permalink
added --jslint-reporter option
Browse files Browse the repository at this point in the history
  • Loading branch information
brentlintner committed Mar 27, 2011
1 parent f7cf4ac commit b842187
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 4 additions & 3 deletions HELP
Expand Up @@ -2,6 +2,7 @@ Usage: jshint path path2 [options]

Options:

--version display package version
--config custom config file
--reporter custom reporter
--version display package version
--config custom config file
--reporter custom reporter
--jslint-reporter use a jslint compatible xml reporter
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -20,6 +20,9 @@ see example/
// custom reporter
--reporter path/to/reporter.js

// use a jslint compatible xml reporter
--jslint-reporter

## Default Options

The cli uses the default options that come with jshint, however if it locates a .jshintrc file in your home (~/) directory it will opt for that.
Expand Down
4 changes: 4 additions & 0 deletions lib/cli.js
Expand Up @@ -30,6 +30,10 @@ module.exports = {
return;
}

if (options["--jslint-reporter"]) {
customReporter = __dirname + "/jslint_reporter.js";
}

if (customConfig) {
try {
config = JSON.parse(_fs.readFileSync(customConfig, "utf-8"));
Expand Down
10 changes: 10 additions & 0 deletions test/cli.js
Expand Up @@ -75,4 +75,14 @@ describe("cli", function () {
expect(sys.print.mostRecentCall.args[0]).toEqual(data.version + "\n");
});

it("interprets --jslint-reporter and uses the jslint xml reporter", function () {
var reporter = "function reporter() {}";
spyOn(fs, "readFileSync").andReturn(reporter);

cli.interpret(["node", "file.js", "file.js", "--jslint-reporter"]);

expect(fs.readFileSync.mostRecentCall.args[0]).toEqual(__dirname.replace(/test$/, '') + "lib/jslint_reporter.js");
expect(hint.hint.mostRecentCall.args[2].toString()).toEqual(reporter);
});

});

0 comments on commit b842187

Please sign in to comment.