Skip to content

Commit

Permalink
Don't use require('./run-log.js').runLog
Browse files Browse the repository at this point in the history
If you happen to introduce a circular require into the stack, this
object will be undefined.

Instead, hang on to `require('./run-log.js')`, which is the exports
module which does get filled in later.
  • Loading branch information
glasser committed Apr 1, 2014
1 parent 241ba37 commit 3e76ad7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tools/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var release = require('./release.js');
var Fiber = require('fibers');
var Future = require(path.join('fibers', 'future'));
var sourcemap = require('source-map');
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');


// files to ignore when bundling. node has no globs, so use regexps
Expand Down
2 changes: 1 addition & 1 deletion tools/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var auth = require('./auth.js');
var config = require('./config.js');
var release = require('./release.js');
var Future = require('fibers/future');
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');

// Given a site name passed on the command line (eg, 'mysite'), return
// a fully-qualified hostname ('mysite.meteor.com').
Expand Down
2 changes: 1 addition & 1 deletion tools/meteor-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var files = require(path.join(__dirname, 'files.js'));
var httpHelpers = require('./http-helpers.js');
var buildmessage = require('./buildmessage.js');
var utils = require('./utils.js');
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');
var _ = require('underscore');

var meteorNpm = exports;
Expand Down
2 changes: 1 addition & 1 deletion tools/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var files = require('./files.js');
var inFiber = require('./fiber-helpers.js').inFiber;
var release = require('./release.js');

var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');
var Proxy = require('./run-proxy.js').Proxy;
var AppRunner = require('./run-app.js').AppRunner;
var MongoRunner = require('./run-mongo.js').MongoRunner;
Expand Down
2 changes: 1 addition & 1 deletion tools/run-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var bundler = require('./bundler.js');
var release = require('./release.js');
var buildmessage = require('./buildmessage.js');
var inFiber = require('./fiber-helpers.js').inFiber;
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');

// Parse out s as if it were a bash command line.
var bashParse = function (s) {
Expand Down
11 changes: 9 additions & 2 deletions tools/run-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,12 @@ _.extend(RunLog.prototype, {
}
});

// Export a singleton instance of RunLog.
exports.runLog = new RunLog;
// Create a singleton instance of RunLog. Expose its public methods on the
// object you get with require('./run-log.js').
var runLogInstance = new RunLog;
_.each(
['log', 'logTemporary', 'logRestart', 'logAppOutput', 'setRawLogs',
'finish', 'clearLog', 'getLog'],
function (method) {
exports[method] = _.bind(runLogInstance[method], runLogInstance);
});
2 changes: 1 addition & 1 deletion tools/run-mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var utils = require('./utils.js');
var release = require('./release.js');
var mongoExitCodes = require('./mongo-exit-codes.js');
var inFiber = require('./fiber-helpers.js').inFiber;
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');

var _ = require('underscore');
var unipackage = require('./unipackage.js');
Expand Down
2 changes: 1 addition & 1 deletion tools/run-proxy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _ = require('underscore');
var Future = require('fibers/future');
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');

// options: listenPort, proxyToPort, onFailure
var Proxy = function (options) {
Expand Down
2 changes: 1 addition & 1 deletion tools/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var warehouse = require('./warehouse.js');
var httpHelpers = require('./http-helpers.js');
var config = require('./config.js');
var release = require('./release.js');
var runLog = require('./run-log.js').runLog;
var runLog = require('./run-log.js');

/**
* Downloads the current manifest file and returns it. Throws
Expand Down

0 comments on commit 3e76ad7

Please sign in to comment.