From 46422ddd99a798d1af9ea337629f2de5334d72fa Mon Sep 17 00:00:00 2001 From: Alexandr Pantyuhov Date: Fri, 4 Mar 2016 20:26:31 -0800 Subject: [PATCH] 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 --- local-cli/runAndroid/runAndroid.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/local-cli/runAndroid/runAndroid.js b/local-cli/runAndroid/runAndroid.js index 8cd14884a..cd369613b 100644 --- a/local-cli/runAndroid/runAndroid.js +++ b/local-cli/runAndroid/runAndroid.js @@ -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']); }