Ability to supply product flavor for `react-native run-android` command

Summary:This small update to runAndroid.js allows to specify product flavor as optional argument, like that:
`react-native run-android --option-flavor=staging`

This option is useful when developing complex applications that require some flavor-specific functionality. More information about productFlavors can be found here: http://developer.android.com/intl/ru/tools/building/configuring-gradle.html
Closes https://github.com/facebook/react-native/pull/6010

Differential Revision: D3011662

Pulled By: mkonicek

fb-gh-sync-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
shipit-source-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
This commit is contained in:
Alexandr Pantyuhov 2016-03-04 20:26:31 -08:00 committed by Facebook Github Bot 1
parent 2d27cf0ceb
commit 46422ddd99
1 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,10 @@ function _runAndroid(argv, config, resolve, reject) {
command: 'root',
type: 'string',
description: 'Override the root directory for the android build (which contains the android directory)',
}, {
command: 'flavor',
type: 'string',
required: false,
}], argv);
args.root = args.root || '';
@ -70,7 +74,15 @@ function buildAndRun(args, reject) {
? 'gradlew.bat'
: './gradlew';
const gradleArgs = ['installDebug'];
const gradleArgs = [];
if (args['flavor']) {
gradleArgs.push('install' +
args['flavor'][0].toUpperCase() + args['flavor'].slice(1)
);
} else {
gradleArgs.push('installDebug');
}
if (args['install-debug']) {
gradleArgs.push(args['install-debug']);
}