forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: fix require('3rdparty') regression
Fix module loading of third-party modules in the REPL by inheriting module.paths from the REPL's parent module. Commit ee72ee7 ("module,repl: remove repl require() hack") introduced a regression where require() of modules in node_modules directories no longer worked in the REPL (and fortunately only in the REPL.) It turns out we didn't have test coverage for that but we do now. Fixes: nodejs#4208 PR-URL: nodejs#4215 Reviewed-By: Roman Reiss <me@silverwind.io>
- Loading branch information
1 parent
1782577
commit 82c9778
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
process.chdir(common.fixturesDir); | ||
const repl = require('repl'); | ||
|
||
const server = net.createServer(conn => { | ||
repl.start('', conn).on('exit', () => { | ||
conn.destroy(); | ||
server.close(); | ||
}); | ||
}); | ||
|
||
const host = common.localhostIPv4; | ||
const port = common.PORT; | ||
const options = { host, port }; | ||
|
||
var answer = ''; | ||
server.listen(options, function() { | ||
const conn = net.connect(options); | ||
conn.setEncoding('utf8'); | ||
conn.on('data', data => answer += data); | ||
conn.write('require("baz")\n.exit\n'); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.strictEqual(false, /Cannot find module/.test(answer)); | ||
assert.strictEqual(false, /Error/.test(answer)); | ||
assert.strictEqual(true, /eye catcher/.test(answer)); | ||
}); |