| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 02e8187 commit 698bf2e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,8 @@ const REPL = require('repl'); | |||
| 5 | 5 | const path = require('path'); | |
| 6 | 6 | const fs = require('fs'); | |
| 7 | 7 | const os = require('os'); | |
| 8 | - const debug = require('util').debuglog('repl'); | ||
| 8 | + const util = require('util'); | ||
| 9 | + const debug = util.debuglog('repl'); | ||
| 9 | 10 | ||
| 10 | 11 | module.exports = Object.create(REPL); | |
| 11 | 12 | module.exports.createInternalRepl = createRepl; | |
@@ -19,11 +20,11 @@ function createRepl(env, opts, cb) { | |||
| 19 | 20 | cb = opts; | |
| 20 | 21 | opts = null; | |
| 21 | 22 | } | |
| 22 | - opts = opts || { | ||
| 23 | + opts = util._extend({ | ||
| 23 | 24 | ignoreUndefined: false, | |
| 24 | 25 | terminal: process.stdout.isTTY, | |
| 25 | 26 | useGlobal: true | |
| 26 | - }; | ||
| 27 | + }, opts); | ||
| 27 | 28 | ||
| 28 | 29 | if (parseInt(env.NODE_NO_READLINE)) { | |
| 29 | 30 | opts.terminal = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | // Flags: --expose-internals | |
| 4 | 4 | ||
| 5 | - require('../common'); | ||
| 5 | + const common = require('../common'); | ||
| 6 | 6 | const stream = require('stream'); | |
| 7 | 7 | const REPL = require('internal/repl'); | |
| 8 | 8 | const assert = require('assert'); | |
@@ -46,6 +46,10 @@ function run(test) { | |||
| 46 | 46 | ||
| 47 | 47 | REPL.createInternalRepl(env, opts, function(err, repl) { | |
| 48 | 48 | if (err) throw err; | |
| 49 | + | ||
| 50 | + // The REPL registers 'module' and 'require' globals | ||
| 51 | + common.allowGlobals(repl.context.module, repl.context.require); | ||
| 52 | + | ||
| 49 | 53 | assert.equal(expected.terminal, repl.terminal, | |
| 50 | 54 | 'Expected ' + inspect(expected) + ' with ' + inspect(env)); | |
| 51 | 55 | assert.equal(expected.useColors, repl.useColors, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,10 @@ const replHistoryPath = path.join(common.tmpDir, '.node_repl_history'); | |||
| 35 | 35 | const checkResults = common.mustCall(function(err, r) { | |
| 36 | 36 | if (err) | |
| 37 | 37 | throw err; | |
| 38 | + | ||
| 39 | + // The REPL registers 'module' and 'require' globals | ||
| 40 | + common.allowGlobals(r.context.module, r.context.require); | ||
| 41 | + | ||
| 38 | 42 | r.input.end(); | |
| 39 | 43 | const stat = fs.statSync(replHistoryPath); | |
| 40 | 44 | assert.strictEqual( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,6 +262,12 @@ function runTest(assertCleaned) { | |||
| 262 | 262 | throw err; | |
| 263 | 263 | } | |
| 264 | 264 | ||
| 265 | + // The REPL registers 'module' and 'require' globals. | ||
| 266 | + // This test also registers '_'. | ||
| 267 | + common.allowGlobals(repl.context.module, | ||
| 268 | + repl.context.require, | ||
| 269 | + repl.context._); | ||
| 270 | + | ||
| 265 | 271 | repl.once('close', () => { | |
| 266 | 272 | if (repl._flushing) { | |
| 267 | 273 | repl.once('flushHistory', onClose); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments