Comparing version 2.2.0 to 2.3.0
@@ -34,3 +34,12 @@ #!/usr/bin/env node | ||
if (commands.indexOf(cmd) === -1) { | ||
client.lint(process.argv.slice(2)); | ||
var useStdIn = (process.argv.indexOf('--stdin') > -1); | ||
if (useStdIn) { | ||
var concat = require('concat-stream'); | ||
process.stdin.pipe(concat({ encoding: 'string' }, function (text) { | ||
client.lint(process.argv.slice(2), text); | ||
})); | ||
} else { | ||
client.lint(process.argv.slice(2)); | ||
} | ||
} else { | ||
@@ -37,0 +46,0 @@ client[cmd](process.argv.slice(3)); |
# Changes | ||
## 2.3.0 | ||
Richard Herrera implemented a missing eslint feature to [lint text provided via | ||
stdin][]. This also fixes [issue #13][]. | ||
[lint text provided on stdin]: https://github.com/mantoni/eslint_d.js/pull/15 | ||
[issue #13]: https://github.com/mantoni/eslint_d.js/issues/13 | ||
## 2.2.0 | ||
@@ -4,0 +12,0 @@ |
@@ -46,4 +46,4 @@ 'use strict'; | ||
exports.lint = function (args) { | ||
if (!args.length) { | ||
exports.lint = function (args, text) { | ||
if (!args.length && !text) { | ||
process.stdout.write('No files specified\n'); | ||
@@ -62,3 +62,4 @@ return; | ||
cwd: process.cwd(), | ||
args: args | ||
args: args, | ||
text: text | ||
})); | ||
@@ -65,0 +66,0 @@ } |
@@ -28,3 +28,3 @@ 'use strict'; | ||
module.exports = function (cwd, args) { | ||
module.exports = function (cwd, args, text) { | ||
process.chdir(cwd); | ||
@@ -39,7 +39,13 @@ var cwdEslint = eslintMap[cwd]; | ||
var files = currentOptions._; | ||
if (!files.length) { | ||
var stdin = currentOptions.stdin; | ||
if (!files.length && (!stdin || !text)) { | ||
return options.generateHelp() + '\n'; | ||
} | ||
var engine = new cwdEslint.CLIEngine(translateOptions(currentOptions)); | ||
var report = engine.executeOnFiles(files); | ||
var report; | ||
if (stdin && text) { | ||
report = engine.executeOnText(text, currentOptions.stdinFilename); | ||
} else { | ||
report = engine.executeOnFiles(files); | ||
} | ||
if (currentOptions.quiet) { | ||
@@ -46,0 +52,0 @@ report.results = cwdEslint.CLIEngine.getErrorResults(report.results); |
@@ -101,2 +101,16 @@ 'use strict'; | ||
{ | ||
heading: 'Using stdin' | ||
}, | ||
{ | ||
option: 'stdin', | ||
type: 'Boolean', | ||
default: 'false', | ||
description: 'Lint code provided on <STDIN>' | ||
}, | ||
{ | ||
option: 'stdin-filename', | ||
type: 'String', | ||
description: 'Specify filename to process STDIN as' | ||
}, | ||
{ | ||
heading: 'Handling warnings' | ||
@@ -103,0 +117,0 @@ }, |
@@ -25,3 +25,3 @@ 'use strict'; | ||
} | ||
var cwd, args; | ||
var cwd, args, text; | ||
if (data.substring(0, 1) === '{') { | ||
@@ -31,2 +31,3 @@ var json = JSON.parse(data); | ||
args = json.args; | ||
text = json.text; | ||
} else { | ||
@@ -38,3 +39,3 @@ var parts = data.split(' '); | ||
try { | ||
con.write(linter(cwd, args)); | ||
con.write(linter(cwd, args, text)); | ||
} catch (e) { | ||
@@ -41,0 +42,0 @@ con.write(e.toString() + '\n'); |
{ | ||
"name": "eslint_d", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Makes eslint the fastest linter on the planet", | ||
@@ -11,2 +11,5 @@ "bin": "bin/eslint_d.js", | ||
"author": "Maximilian Antoni <mail@maxantoni.de> (http://maxantoni.de/)", | ||
"contributors": [ | ||
"Richard Herrera <rich@doctyper.com>" | ||
], | ||
"homepage": "https://github.com/mantoni/eslint_d.js", | ||
@@ -21,2 +24,3 @@ "scripts": { | ||
"dependencies": { | ||
"concat-stream": "^1.5.1", | ||
"eslint": "^1.4.2", | ||
@@ -23,0 +27,0 @@ "optionator": "^0.5.0", |
17544
462
4
+ Addedconcat-stream@^1.5.1