Files
meteor/tools/cli/dev-bundle-bin-commands.js
Ben Newman 4300d261f3 Support meteor <command> for any dev_bundle/bin/<command> executable.
This will make it easier to use tools like https://yarnpkg.com/ with the
right version of Node, etc.

With this commit, here's all you have to do:

  meteor npm install -g yarnpkg

Then test that it works:

  meteor yarn info

Note that any commands registered by Meteor itself will not be honored.
2016-10-12 13:22:26 -04:00

51 lines
1.3 KiB
JavaScript

// 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 fs = require("fs");
var path = require("path");
// The dev_bundle/bin command has to come immediately after the meteor
// command, as in `meteor npm` or `meteor node`, because we don't want to
// require("./main.js") for these commands.
var devBundleBinCommand = process.argv[2];
var args = process.argv.slice(3);
function getChildProcess() {
if (typeof devBundleBinCommand !== "string") {
return Promise.resolve(null);
}
var helpers = require("./dev-bundle-bin-helpers.js");
return Promise.all([
helpers.getDevBundle(),
helpers.getEnv()
]).then(function (devBundleAndEnv) {
var devBundleDir = devBundleAndEnv[0];
var cmd = helpers.getCommand(devBundleBinCommand, devBundleDir);
if (! cmd) {
return null;
}
var env = devBundleAndEnv[1];
var child = require("child_process").spawn(cmd, args, {
stdio: "inherit",
env: env
});
require("./flush-buffers-on-exit-in-windows.js");
child.on("error", function (error) {
console.log(error.stack || error);
});
child.on("exit", function (exitCode) {
process.exit(exitCode);
});
return child;
});
}
module.exports = getChildProcess();