Skip to content

Instantly share code, notes, and snippets.

@evanlucas
Last active August 29, 2015 14:22
Show Gist options
  • Save evanlucas/16fc21c141841e0724c3 to your computer and use it in GitHub Desktop.
Save evanlucas/16fc21c141841e0724c3 to your computer and use it in GitHub Desktop.
allow node -ie
commit 09e46c3d48d9c81daa68e4dc69a249fa80b3287f
Author: Evan Lucas <[email protected]>
Date: Mon Jun 1 10:17:19 2015 -0500
allow -ie
diff --git a/src/node.js b/src/node.js
index 2516478..d370ce0 100644
--- a/src/node.js
+++ b/src/node.js
@@ -86,6 +86,8 @@
// User passed '-e' or '--eval' arguments to Node.
startup.preloadModules();
evalScript('[eval]');
+ if (process._forceRepl)
+ startup.processInteractive();
} else if (process.argv[1]) {
// make process.argv[1] into a full path
var path = NativeModule.require('path');
@@ -118,26 +120,9 @@
}
} else {
- var Module = NativeModule.require('module');
-
// If -i or --interactive were passed, or stdin is a TTY.
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
- // REPL
- var cliRepl = Module.requireRepl();
- cliRepl.createInternalRepl(process.env, function(err, repl) {
- if (err) {
- throw err;
- }
- repl.on('exit', function() {
- if (repl._flushing) {
- repl.pause();
- return repl.once('flushHistory', function() {
- process.exit();
- });
- }
- process.exit();
- });
- });
+ startup.processInteractive();
} else {
// Read all of stdin - execute it.
process.stdin.setEncoding('utf8');
@@ -238,6 +223,26 @@
};
};
+ startup.processInteractive = function() {
+ // REPL
+ var Module = NativeModule.require('module');
+ var cliRepl = Module.requireRepl();
+ cliRepl.createInternalRepl(process.env, function(err, repl) {
+ if (err) {
+ throw err;
+ }
+ repl.on('exit', function() {
+ if (repl._flushing) {
+ repl.pause();
+ return repl.once('flushHistory', function() {
+ process.exit();
+ });
+ }
+ process.exit();
+ });
+ });
+ }
+
startup.processConfig = function() {
// used for `process.config`, but not a real module
var config = NativeModule._source.config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment