Make 'npm start' an alias for 'packager.sh', don't silently no-op on Windows

Reviewed By: martinbigio

Differential Revision: D2559772

fb-gh-sync-id: d1cd2874c32459d6e1f0af7d084c3559ebc145aa
This commit is contained in:
Martin Konicek 2015-10-20 10:13:36 -07:00 committed by facebook-github-bot-9
parent e612690413
commit 4ac3c4a853
2 changed files with 22 additions and 4 deletions

View File

@ -15,13 +15,13 @@ var generate = require('../private-cli/src/generate/generate');
var init = require('./init.js');
var library = require('../private-cli/src/library/library');
var runAndroid = require('./run-android.js');
var runPackager = require('./run-packager.js');
var server = require('../private-cli/src/server/server');
// TODO: remove once we fully roll out the `private-cli` based cli
// var bundle_DEPRECATED = require('./bundle.js');
// var generateAndroid_DEPRECATED = require('./generate-android.js');
// var newLibrary_DEPRECATED = require('./new-library.js');
// var runPackager_DEPRECATED = require('./run-packager.js');
function printUsage() {
console.log([
@ -31,7 +31,8 @@ function printUsage() {
' start: starts the webserver',
' bundle: builds the javascript bundle for offline use',
' new-library: generates a native library bridge',
' android: generates an Android project for your app'
' android: generates an Android project for your app',
' run-android: builds your app and starts it on a connected Android emulator or device'
].join('\n'));
process.exit(1);
}
@ -53,8 +54,7 @@ function run() {
var config = Config.get(__dirname);
switch (args[0]) {
case 'start':
server(args, config).done();
// runPackager_DEPRECATED();
runPackager(false);
break;
case 'bundle':
bundle(args, config).done();
@ -86,6 +86,9 @@ function run() {
case 'run-android':
runAndroid();
break;
case 'help':
printUsage();
break;
default:
console.error('Command `%s` unrecognized', args[0]);
printUsage();

View File

@ -8,9 +8,14 @@
*/
'use strict';
var chalk = require('chalk');
var path = require('path');
var child_process = require('child_process');
/**
* Main entry point to starting the packager from JS.
* @param {boolean} newWindow If true, will start the packager in a new shell window.
*/
module.exports = function(newWindow) {
if (newWindow) {
var launchPackagerScript =
@ -22,6 +27,16 @@ module.exports = function(newWindow) {
'xterm',
['-e', 'sh', launchPackagerScript],
{detached: true});
} else if (/^win/.test(process.platform)) {
console.log(chalk.yellow('Starting the packager in a new window ' +
'is not supported on Windows yet.\nPlease start it manually using ' +
'\'react-native start\'.'));
console.log('We believe the best Windows ' +
'support will come from a community of people\nusing React Native on ' +
'Windows on a daily basis.\n' +
'Would you be up for sending a pull request?');
} else {
console.log('Cannot start the packager. Unknown platform ' + process.platform);
}
} else {
if (/^win/.test(process.platform)) {