From 96dda4bf5f91cfa03ed0c414346dc3d79b787f20 Mon Sep 17 00:00:00 2001 From: Andrei Coman Date: Mon, 12 Oct 2015 08:34:33 -0700 Subject: [PATCH] Revert D2531438 Differential Revision: D2531532 fb-gh-sync-id: c86bbcde3254df78f3dca88285ef1cd5a3563123 --- private-cli/src/bundle/bundle.js | 33 +++++++++++++- .../src/bundle/parseBundleCommandLine.js | 44 ------------------- private-cli/src/cli.js | 11 ++--- 3 files changed, 35 insertions(+), 53 deletions(-) delete mode 100644 private-cli/src/bundle/parseBundleCommandLine.js diff --git a/private-cli/src/bundle/bundle.js b/private-cli/src/bundle/bundle.js index 20bbf59fb..f66bda2b5 100644 --- a/private-cli/src/bundle/bundle.js +++ b/private-cli/src/bundle/bundle.js @@ -9,7 +9,7 @@ 'use strict'; const log = require('../util/log').out('bundle'); -const parseBundleCommandLine = require('./parseBundleCommandLine'); +const parseCommandLine = require('../../../packager/parseCommandLine'); const processBundle = require('./processBundle'); const Promise = require('promise'); const ReactPackager = require('../../../packager/react-packager'); @@ -25,7 +25,36 @@ function bundle(argv, config) { } function _bundle(argv, config, resolve, reject) { - const args = parseBundleCommandLine(argv); + const args = parseCommandLine([ + { + command: 'entry-file', + description: 'Path to the root JS file, either absolute or relative to JS root', + type: 'string', + required: true, + }, { + command: 'platform', + description: 'Either "ios" or "android"', + type: 'string', + required: true, + }, { + command: 'dev', + description: 'If false, warnings are disabled and the bundle is minified', + default: true, + }, { + command: 'bundle-output', + description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle', + type: 'string', + required: true, + }, { + command: 'sourcemap-output', + description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map', + type: 'string', + }, { + command: 'assets-dest', + description: 'Directory name where to store assets referenced in the bundle', + type: 'string', + } + ], argv); // This is used by a bazillion of npm modules we don't control so we don't // have other choice than defining it as an env variable here. diff --git a/private-cli/src/bundle/parseBundleCommandLine.js b/private-cli/src/bundle/parseBundleCommandLine.js deleted file mode 100644 index e9f54339c..000000000 --- a/private-cli/src/bundle/parseBundleCommandLine.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -'use strict'; - -const parseCommandLine = require('../../../packager/parseCommandLine'); - -module.exports = function(argv) { - return parseCommandLine([ - { - command: 'entry-file', - description: 'Path to the root JS file, either absolute or relative to JS root', - type: 'string', - required: true, - }, { - command: 'platform', - description: 'Either "ios" or "android"', - type: 'string', - required: true, - }, { - command: 'dev', - description: 'If false, warnings are disabled and the bundle is minified', - default: true, - }, { - command: 'bundle-output', - description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle', - type: 'string', - required: true, - }, { - command: 'sourcemap-output', - description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map', - type: 'string', - }, { - command: 'assets-dest', - description: 'Directory name where to store assets referenced in the bundle', - type: 'string', - } - ], argv); -}; diff --git a/private-cli/src/cli.js b/private-cli/src/cli.js index 44dd1d098..679c46d00 100644 --- a/private-cli/src/cli.js +++ b/private-cli/src/cli.js @@ -29,16 +29,16 @@ const hiddenCommands = { */ function run(command, commandArgs) { if (!command) { - return Promise.reject(helpMessage()); + throw new Error(helpMessage()); } commandArgs = commandArgs || []; const commandToExec = documentedCommands[command] || hiddenCommands[command]; if (!commandToExec) { - return Promise.reject(helpMessage(command)); + throw new Error(helpMessage(command)); } - return commandToExec(commandArgs, Config.get()); + commandToExec(commandArgs, Config.get()).done(); } function helpMessage(command) { @@ -61,7 +61,4 @@ function help() { return Promise.resolve(); } -module.exports = { - run: run, - commands: documentedCommands, -}; +module.exports.run = run;