summaryrefslogtreecommitdiff
path: root/tools/eslint/bin/eslint.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/bin/eslint.js')
-rwxr-xr-xtools/eslint/bin/eslint.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/eslint/bin/eslint.js b/tools/eslint/bin/eslint.js
new file mode 100755
index 0000000000..0188c2e600
--- /dev/null
+++ b/tools/eslint/bin/eslint.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+var concat = require("concat-stream"),
+ cli = require("../lib/cli");
+
+var exitCode = 0,
+ useStdIn = (process.argv.indexOf("--stdin") > -1);
+
+if (useStdIn) {
+ process.stdin.pipe(concat({ encoding: "string" }, function(text) {
+ try {
+ exitCode = cli.execute(process.argv, text);
+ } catch (ex) {
+ console.error(ex.message);
+ console.error(ex.stack);
+ exitCode = 1;
+ }
+ }));
+} else {
+ exitCode = cli.execute(process.argv);
+}
+
+/*
+ * Wait for the stdout buffer to drain.
+ * See https://github.com/eslint/eslint/issues/317
+ */
+process.on("exit", function() {
+ process.exit(exitCode);
+});