Ensure that require and module are always set.

I previously had thought that a duplicate call to `setRequireAndModule`
encountered in code-path would no longer be necessary after some
consolidation in previous steps of this re-factor, but the test failure
seen here made it clear what was happening:

https://circleci.com/gh/meteor/meteor/12445

Specifically, if a module was imported in a piped command (that is to say,
when no TTY is present and the `evaluateAndExit` code-path is taken), as so:

    echo 'import { Meteor } from "meteor/meteor"' | meteor shell

...the `module` and `require` symbols were not set.  Conveniently, this is
the environment in effect when the `meteor self-test` suite is ran since
they do not have a TTY.

This moves the `setAndRequire` from the "interactive-only" function into
the general REPL setup and further harmonizes the code.
This commit is contained in:
Jesse Rosenberger
2017-11-28 18:35:04 +02:00
parent 724a801d70
commit 0df8a5a516

View File

@@ -222,6 +222,8 @@ class Server {
repl.context = global;
repl.useGlobal = true;
setRequireAndModule(repl.context);
// In order to avoid duplicating code here, specifically the complexities
// of catching so-called "Recoverable Errors" (https://git.io/vbvbl),
// we will wrap the default eval, run it in a Fiber (via a Promise), and
@@ -270,8 +272,6 @@ class Server {
configurable: true
});
setRequireAndModule(repl.context);
// Some improvements to the existing help messages.
function addHelp(cmd, helpText) {
const info = repl.commands[cmd] || repl.commands["." + cmd];