Skip to content

Commit

Permalink
Ability to supply product flavor for react-native run-android command
Browse files Browse the repository at this point in the history
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 #6010

Differential Revision: D3011662

Pulled By: mkonicek

fb-gh-sync-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
shipit-source-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
  • Loading branch information
alwx authored and Facebook Github Bot 1 committed Mar 5, 2016
1 parent 2d27cf0 commit 46422dd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion local-cli/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
Expand Down Expand Up @@ -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']);
}
Expand Down

0 comments on commit 46422dd

Please sign in to comment.