| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8c4c84f commit 4ecd996
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,8 +88,9 @@ | |||
| 88 | 88 | delete process.env.NODE_UNIQUE_ID; | |
| 89 | 89 | } | |
| 90 | 90 | ||
| 91 | - if (process._eval != null) { | ||
| 92 | - // User passed '-e' or '--eval' arguments to Node. | ||
| 91 | + if (process._eval != null && !process._forceRepl) { | ||
| 92 | + // User passed '-e' or '--eval' arguments to Node without '-i' or | ||
| 93 | + // '--interactive' | ||
| 93 | 94 | startup.preloadModules(); | |
| 94 | 95 | evalScript('[eval]'); | |
| 95 | 96 | } else if (process.argv[1]) { | |
@@ -161,6 +162,11 @@ | |||
| 161 | 162 | process.exit(); | |
| 162 | 163 | }); | |
| 163 | 164 | }); | |
| 165 | + | ||
| 166 | + if (process._eval != null) { | ||
| 167 | + // User passed '-e' or '--eval' | ||
| 168 | + evalScript('[eval]'); | ||
| 169 | + } | ||
| 164 | 170 | } else { | |
| 165 | 171 | // Read all of stdin - execute it. | |
| 166 | 172 | process.stdin.setEncoding('utf8'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const spawn = require('child_process').spawn; | ||
| 5 | + | ||
| 6 | + // spawn a node child process in "interactive" mode (force the repl) and eval | ||
| 7 | + const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']); | ||
| 8 | + var gotToEnd = false; | ||
| 9 | + const timeoutId = setTimeout(function() { | ||
| 10 | + throw new Error('timeout!'); | ||
| 11 | + }, common.platformTimeout(1000)); // give node + the repl 1 second to boot up | ||
| 12 | + | ||
| 13 | + cp.stdout.setEncoding('utf8'); | ||
| 14 | + | ||
| 15 | + var output = ''; | ||
| 16 | + cp.stdout.on('data', function(b) { | ||
| 17 | + output += b; | ||
| 18 | + if (output === '> 42\n') { | ||
| 19 | + clearTimeout(timeoutId); | ||
| 20 | + gotToEnd = true; | ||
| 21 | + cp.kill(); | ||
| 22 | + } | ||
| 23 | + }); | ||
| 24 | + | ||
| 25 | + process.on('exit', function() { | ||
| 26 | + assert(gotToEnd); | ||
| 27 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments