File tree Expand file tree Collapse file tree 3 files changed +22
-15
lines changed Expand file tree Collapse file tree 3 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- module . exports = { createRepl : createRepl } ;
4-
53const Interface = require ( 'readline' ) . Interface ;
64const REPL = require ( 'repl' ) ;
75const path = require ( 'path' ) ;
86
7+ module . exports = Object . create ( REPL ) ;
8+ module . exports . createInternalRepl = createRepl ;
9+
910// XXX(chrisdickinson): The 15ms debounce value is somewhat arbitrary.
1011// The debounce is to guard against code pasted into the REPL.
1112const kDebounceHistoryMS = 15 ;
1213
13- try {
14- // hack for require.resolve("./relative") to work properly.
15- module . filename = path . resolve ( 'repl' ) ;
16- } catch ( e ) {
17- // path.resolve('repl') fails when the current working directory has been
18- // deleted. Fall back to the directory name of the (absolute) executable
19- // path. It's not really correct but what are the alternatives?
20- const dirname = path . dirname ( process . execPath ) ;
21- module . filename = path . resolve ( dirname , 'repl' ) ;
14+ // XXX(chrisdickinson): hack to make sure that the internal debugger
15+ // uses the original repl.
16+ function replStart ( ) {
17+ return REPL . start . apply ( REPL , arguments ) ;
2218}
2319
24- // hack for repl require to work properly with node_modules folders
25- module . paths = require ( 'module' ) . _nodeModulePaths ( module . filename ) ;
26-
2720function createRepl ( env , cb ) {
2821 const opts = {
2922 ignoreUndefined : false ,
Original file line number Diff line number Diff line change @@ -32,6 +32,20 @@ const Console = require('console').Console;
3232const domain = require ( 'domain' ) ;
3333const debug = util . debuglog ( 'repl' ) ;
3434
35+ try {
36+ // hack for require.resolve("./relative") to work properly.
37+ module . filename = path . resolve ( 'repl' ) ;
38+ } catch ( e ) {
39+ // path.resolve('repl') fails when the current working directory has been
40+ // deleted. Fall back to the directory name of the (absolute) executable
41+ // path. It's not really correct but what are the alternatives?
42+ const dirname = path . dirname ( process . execPath ) ;
43+ module . filename = path . resolve ( dirname , 'repl' ) ;
44+ }
45+
46+ // hack for repl require to work properly with node_modules folders
47+ module . paths = require ( 'module' ) . _nodeModulePaths ( module . filename ) ;
48+
3549// If obj.hasOwnProperty has been overridden, then calling
3650// obj.hasOwnProperty(prop) will break.
3751// See: https://github.com/joyent/node/issues/1707
Original file line number Diff line number Diff line change 130130 // If -i or --interactive were passed, or stdin is a TTY.
131131 if ( process . _forceRepl || NativeModule . require ( 'tty' ) . isatty ( 0 ) ) {
132132 // REPL
133- Module . requireRepl ( ) . createRepl ( process . env , function ( err , repl ) {
133+ Module . requireRepl ( ) . createInternalRepl ( process . env , function ( err , repl ) {
134134 if ( err ) {
135135 throw err ;
136136 }
You can’t perform that action at this time.
0 commit comments