Skip to content

Commit

Permalink
meteor shell should preserve global _
Browse files Browse the repository at this point in the history
2443d83 (in 1.0.4) ensures that the repl doesn't overwrite `_`, but it
replaces the server's global `_` with shell-server's `_`.  This changes
appears to preserve it.

Fixes meteor#4010.
  • Loading branch information
glasser committed Mar 26, 2015
1 parent d226fd1 commit da87051
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/server/shell-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ Sp.startREPL = function startREPL(options) {
// History persists across shell sessions!
self.initializeHistory();

// Save the global `_` object in the server. This is probably defined by the
// underscore package. It is unlikely to be the same object as the `var _ =
// require('underscore')` in this file!
var originalUnderscore = repl.context._;

Object.defineProperty(repl.context, "_", {
// Force the global _ variable to remain bound to underscore.
get: function () { return _; },
get: function () { return originalUnderscore; },

// Expose the last REPL result as __ instead of _.
set: function(lastResult) {
Expand Down

0 comments on commit da87051

Please sign in to comment.