Permalink
Browse files

Support overwriting JSHINT options in command line (implements #27)

Note that the predef syntax is `jshint FILE.js --predef require module`.
  • Loading branch information...
1 parent 601d111 commit 3fbbe2aa1bc7103685d0ec1e5891ab6346c8d596 @adrianheine committed Apr 23, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/cli.js
View
@@ -93,7 +93,7 @@ module.exports = {
customConfig = options["--config"],
customReporter = options["--reporter"] ? path.resolve(process.cwd(), options["--reporter"]) : null,
targets = options.node,
- ignoreFile, ignores;
+ ignoreFile, ignores, k, nodeArgName = 'node';
//could be on Windows which we are looking for an attribute ending in 'node.exe'
if (targets === undefined) {
@@ -103,6 +103,7 @@ module.exports = {
for (arg in options) {
if (path.basename(arg) === 'node.exe') {
targets = options[arg];
+ nodeArgName = arg;
break;
}
}
@@ -131,6 +132,14 @@ module.exports = {
config = _loadAndParseConfig(customConfig ? customConfig : _findConfig());
+ // Merge JSHINT options given on the command line
+ for (k in options) {
+ if (options.hasOwnProperty(k) &&['--jslint-reporter', nodeArgName,
+ '--show-non-errors'].indexOf(k) === -1) {
+ config[k.replace(/^-+/, '')] = options[k];
+ }
+ }
+
if (customReporter) {
try {
reporter = require(customReporter).reporter;

0 comments on commit 3fbbe2a

Please sign in to comment.