Revert D2531438

Differential Revision: D2531532

fb-gh-sync-id: c86bbcde3254df78f3dca88285ef1cd5a3563123
This commit is contained in:
Andrei Coman
2015-10-12 08:34:33 -07:00
committed by facebook-github-bot-3
parent c075be6cab
commit 96dda4bf5f
3 changed files with 35 additions and 53 deletions

View File

@@ -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.

View File

@@ -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);
};

View File

@@ -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;