babel-node: support require flag in repl mode (#12297)
This commit is contained in:
parent
487f82e446
commit
4141793a37
@ -187,12 +187,7 @@ if (program.eval || program.print) {
|
||||
});
|
||||
args = args.slice(i);
|
||||
|
||||
// We have to handle require ourselves, as we want to require it in the context of babel-register
|
||||
if (program.require) {
|
||||
require(resolve.sync(program.require, {
|
||||
basedir: process.cwd(),
|
||||
}));
|
||||
}
|
||||
requireArgs();
|
||||
|
||||
// make the filename absolute
|
||||
const filename = args[0];
|
||||
@ -206,10 +201,20 @@ if (program.eval || program.print) {
|
||||
|
||||
Module.runMain();
|
||||
} else {
|
||||
requireArgs();
|
||||
replStart();
|
||||
}
|
||||
}
|
||||
|
||||
// We have to handle require ourselves, as we want to require it in the context of babel-register
|
||||
function requireArgs() {
|
||||
if (program.require) {
|
||||
require(resolve.sync(program.require, {
|
||||
basedir: process.cwd(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function replStart() {
|
||||
repl.start({
|
||||
prompt: "babel > ",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user