From 0df8a5a51685bafcd9bbc3b1729f4929fc9c978f Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 28 Nov 2017 18:35:04 +0200 Subject: [PATCH] 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. --- packages/shell-server/shell-server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shell-server/shell-server.js b/packages/shell-server/shell-server.js index 6af15b6c80..ecd66237dd 100644 --- a/packages/shell-server/shell-server.js +++ b/packages/shell-server/shell-server.js @@ -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];