From 688f277162c8bde48b5978b1f3fc4753a2224f2e Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 6 Jan 2016 11:59:21 -0800 Subject: [PATCH] Fix: Set proper exit code for Node > 0.10 (fixes #4691) --- bin/eslint.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/eslint.js b/bin/eslint.js index 86c32946710..598b568ba4e 100755 --- a/bin/eslint.js +++ b/bin/eslint.js @@ -60,10 +60,16 @@ if (useStdIn) { 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); -}); +// https://github.com/eslint/eslint/issues/4691 +// In Node.js >= 0.12, you can use a cleaner way +if ("exitCode" in process) { + process.exitCode = exitCode; +} else { + /* + * Wait for the stdout buffer to drain. + * See https://github.com/eslint/eslint/issues/317 + */ + process.on("exit", function() { + process.exit(exitCode); + }); +}