From eadb6e65cc2887af003f8747418e8a8602ffab33 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 7 Jul 2016 11:04:18 -0400 Subject: [PATCH] Ensure only one Promise constructor is ever used by tools code. --- tools/cli/dev-bundle-bin-commands.js | 2 -- tools/cli/dev-bundle.js | 1 - tools/index.js | 6 ++++++ tools/tool-env/install-runtime.js | 6 ------ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/cli/dev-bundle-bin-commands.js b/tools/cli/dev-bundle-bin-commands.js index 51a98bf63b..19bf936d55 100644 --- a/tools/cli/dev-bundle-bin-commands.js +++ b/tools/cli/dev-bundle-bin-commands.js @@ -1,8 +1,6 @@ // Note that this file is required before we install our Babel hooks in // ../tool-env/install-babel.js, so we can't use ES2015+ syntax here. -var Promise = global.Promise || require("promise/lib/es6-extensions"); - var win32Extensions = { node: ".exe", npm: ".cmd" diff --git a/tools/cli/dev-bundle.js b/tools/cli/dev-bundle.js index 48c07257dc..48313aba88 100644 --- a/tools/cli/dev-bundle.js +++ b/tools/cli/dev-bundle.js @@ -8,7 +8,6 @@ var fs = require("fs"); var path = require("path"); var rootDir = path.resolve(__dirname, "..", ".."); -var Promise = global.Promise || require("promise/lib/es6-extensions"); var defaultDevBundlePromise = Promise.resolve(path.join(rootDir, "dev_bundle")); diff --git a/tools/index.js b/tools/index.js index cc1a1f6544..dbbe16783f 100644 --- a/tools/index.js +++ b/tools/index.js @@ -1,3 +1,9 @@ +// Install a global ES2015-compliant Promise constructor that knows how to +// run all its callbacks in Fibers. +var Promise = global.Promise = global.Promise || + require("promise/lib/es6-extensions"); +require("meteor-promise").makeCompatible(Promise, require("fibers")); + require("./cli/dev-bundle-bin-commands.js").then(function (child) { if (! child) { // Use process.nextTick here to prevent the Promise from swallowing diff --git a/tools/tool-env/install-runtime.js b/tools/tool-env/install-runtime.js index aaa2a938d0..e2a06a5772 100644 --- a/tools/tool-env/install-runtime.js +++ b/tools/tool-env/install-runtime.js @@ -2,12 +2,6 @@ // Symbol, Map, and Set, patching the native implementations if available. require("meteor-ecmascript-runtime"); -// Install a global ES2015-compliant Promise constructor that knows how to -// run all its callbacks in Fibers. -var Promise = global.Promise = global.Promise || - require("promise/lib/es6-extensions"); -require("meteor-promise").makeCompatible(Promise, require("fibers")); - // Verify that the babel-runtime package is available to be required. // The .join("/") prevents babel-plugin-transform-runtime from // "intelligently" converting this to an import statement.