diff --git a/tools/commands.js b/tools/commands.js index 03b953bfca..35d6911aec 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -6,7 +6,6 @@ var files = require('./files.js'); var deploy = require('./deploy.js'); var library = require('./library.js'); var buildmessage = require('./buildmessage.js'); -var unipackage = require('./unipackage.js'); var project = require('./project.js'); var warehouse = require('./warehouse.js'); var auth = require('./auth.js'); @@ -1100,72 +1099,6 @@ main.registerCommand({ }); -/////////////////////////////////////////////////////////////////////////////// -// run-command -/////////////////////////////////////////////////////////////////////////////// - -main.registerCommand({ - name: 'run-command', - hidden: true, - raw: true -}, function (options) { - // This is marked as raw, so we have to do all of our argument - // parsing ourselves. This lets us make sure that the arguments to - // the command being run don't get accidentally intrepreted. - - var library = release.current.library; - var argv = process.argv.slice(3); - if (! argv.length || argv[0] === "--help") - throw new main.ShowUsage; - - if (! fs.existsSync(argv[0]) || - ! fs.statSync(argv[0]).isDirectory()) { - process.stderr.write(argv[0] + ": not a directory\n"); - return 1; - } - - // Build and load the package - var world, packageName; - var messages = buildmessage.capture( - { title: "building the program" }, function () { - // Make the directory visible as a package. Derive the last - // package name from the last component of the directory, and - // bail out if that creates a conflict. - var packageDir = path.resolve(argv[0]); - packageName = path.basename(packageDir) + "-tool"; - if (library.get(packageName, false)) { - buildmessage.error("'" + packageName + - "' conflicts with the name " + - "of a package in the library"); - } - library.override(packageName, packageDir); - - world = unipackage.load({ - library: library, - packages: [ packageName ], - release: release.current.name - }); - }); - if (messages.hasMessages()) { - process.stderr.write(messages.formatMessages()); - return 1; - } - - if (! ('main' in world[packageName])) { - process.stderr.write("Package does not define a main() function.\n"); - return 1; - } - - var ret = world[packageName].main(argv.slice(1)); - // let exceptions propagate and get printed by node - if (ret === undefined) - ret = 0; - if (typeof ret !== "number") - ret = 1; - ret = +ret; // cast to integer - return ret; -}); - /////////////////////////////////////////////////////////////////////////////// // login /////////////////////////////////////////////////////////////////////////////// diff --git a/tools/help.txt b/tools/help.txt index d73ec1524e..6b40730a91 100644 --- a/tools/help.txt +++ b/tools/help.txt @@ -264,19 +264,6 @@ You should never need to use this command. It is intended for use while debugging the Meteor packaging tools themselves. ->>> run-command -Build and run a command-line tool -Usage: meteor run-command [arguments..] - -Builds the provided directory as a package, then loads the package and -calls the main() function inside the package. The function will receive -any remaining arguments. The exit status will be the return value of -main() (which is called inside a fiber). - -This command is for temporary, internal use, until we have a more mature -system for building standalone command-line programs with Meteor. - - >>> login Log in to your Meteor account Usage: meteor login [--email] [--galaxy ] diff --git a/tools/main.js b/tools/main.js index 0d9688cd6c..b004601160 100644 --- a/tools/main.js +++ b/tools/main.js @@ -32,7 +32,6 @@ var Command = function (options) { options: {}, requiresApp: false, requiresRelease: true, - raw: false, hidden: false }, options); @@ -135,10 +134,6 @@ main.SpringboardToLatestRelease = function () {}; // just like we always do; it's just that in that one case, instead // of bailing out with an error we will run your command with // release.current === null. -// - raw: if true, option parsing is completely skipped (including -// --release and --help). To be activated the command will need to be -// literally the first argument, and it will need to do its own option -// parsing from process.argv. // - hidden: do not show in command list in help // // An error will be printed if an unrecognized option is passed on the @@ -185,9 +180,6 @@ main.registerCommand = function (options, func) { nameParts.unshift('--'); } - if (nameParts.length !== 1 && options.raw) - throw new Error("raw mode can't be used with subcommands or --commands"); - var target = commands; while (nameParts.length > 1) { var part = nameParts.shift(); @@ -304,11 +296,10 @@ var springboard = function (toolsVersion, releaseOverride) { var cmd = path.join(warehouse.getToolsDir(toolsVersion), 'bin', 'meteor'); if (releaseOverride !== undefined) - // We used to just append --release= to the - // arguments, and though that's probably safe in practice, there's - // a lot to worry about: conflicts with other --release options, - // or 'raw' commands that do their own argument parsing. So now we - // use environment variable. #SpringboardEnvironmentVar + // We used to just append --release= to the arguments, and + // though that's probably safe in practice, it makes us worry about things + // like other --release options. So now we use an environment + // variable. #SpringboardEnvironmentVar process.env['METEOR_SPRINGBOARD_RELEASE'] = releaseOverride; // Now exec; we're not coming back. @@ -346,21 +337,6 @@ Fiber(function () { process.exit(1); } - var commandName = ''; - var command = null; - var isRawCommand = false; - var showHelp = false; - - // Check to see if it is a "raw" command that handles its own - // argument parsing. - if (process.argv.length > 2 && - _.has(commands, process.argv[2]) && - commands[process.argv[2]].raw) { - command = commands[process.argv[2]]; - commandName = command.name; - isRawCommand = true; - } - // Parse the arguments. // // We must first identify which options are boolean and which take @@ -644,18 +620,22 @@ Fiber(function () { } // Check for the '--help' option. + var showHelp = false; if (_.has(rawOptions, '--help')) { showHelp = true; delete rawOptions['--help']; } + var commandName = ''; + var command = null; + // Check for a command like '--arch' or '--version'. Make sure // it stands alone. (And this is ignored if you've passed --help.) - if (! command) { + if (! showHelp) { _.each(commands['--'] || {}, function (value, key) { var fullName = "--" + key; - if (rawOptions[fullName] && ! showHelp) { + if (rawOptions[fullName]) { if (rawOptions[fullName].length > 1) { process.stderr.write("It doesn't make sense to pass " + fullName + " more than once.\n");