File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed
packages/cli-platform-android/src/commands Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,8 @@ Override the root directory for the Android build (which contains the android di
323323
324324#### ` --variant <string> `
325325
326+ > ** DEPRECATED** – use "mode" instead
327+
326328> default: 'debug'
327329
328330Specify your app's build variant.
Original file line number Diff line number Diff line change 77import { Config } from '@react-native-community/cli-types' ;
88import execa from 'execa' ;
99import { getAndroidProject } from '../../config/getAndroidProject' ;
10- import { getTaskNames , toPascalCase } from '../runAndroid/runOnAllDevices' ;
10+ import { getTaskNames } from '../runAndroid/runOnAllDevices' ;
1111import adb from '../runAndroid/adb' ;
1212import getAdbPath from '../runAndroid/getAdbPath' ;
1313import { startServerInNewWindow } from './startServerInNewWindow' ;
@@ -58,17 +58,13 @@ async function buildAndroid(
5858 ) ;
5959 }
6060
61- const mode = args . variant || args . mode ;
62-
6361 if ( args . tasks && args . mode ) {
6462 logger . warn (
6563 'Both "tasks" and "mode" parameters were passed to "build" command. Using "tasks" for building the app.' ,
6664 ) ;
6765 }
6866
69- const tasks = args . tasks || [ 'assemble' + toPascalCase ( mode ) ] ;
70-
71- let gradleArgs = getTaskNames ( androidProject . appName , tasks ) ;
67+ let gradleArgs = getTaskNames ( androidProject . appName , args , 'assemble' ) ;
7268
7369 if ( args . extraParams ) {
7470 gradleArgs = [ ...gradleArgs , ...args . extraParams ] ;
@@ -117,7 +113,6 @@ export const options = [
117113 {
118114 name : '--mode <string>' ,
119115 description : "Specify your app's build variant" ,
120- default : 'debug' ,
121116 } ,
122117 {
123118 name : '--variant <string>' ,
Original file line number Diff line number Diff line change @@ -16,14 +16,17 @@ import tryLaunchAppOnDevice from './tryLaunchAppOnDevice';
1616import tryLaunchEmulator from './tryLaunchEmulator' ;
1717import tryInstallAppOnDevice from './tryInstallAppOnDevice' ;
1818import { Flags } from '.' ;
19+ import { BuildFlags } from '../buildAndroid' ;
1920
2021export function getTaskNames (
2122 appName : string ,
22- commands : Array < string > ,
23+ args : BuildFlags ,
24+ taskPrefix : 'assemble' | 'install' ,
2325) : Array < string > {
24- return appName
25- ? commands . map ( ( command ) => `${ appName } :${ command } ` )
26- : commands ;
26+ const mode = args . mode || args . variant || 'debug' ;
27+ const tasks = args . tasks || [ taskPrefix + toPascalCase ( mode ) ] ;
28+
29+ return appName ? tasks . map ( ( command ) => `${ appName } :${ command } ` ) : tasks ;
2730}
2831
2932export function toPascalCase ( value : string ) {
@@ -54,13 +57,15 @@ async function runOnAllDevices(
5457 ) ;
5558 }
5659 }
60+ if ( args . variant ) {
61+ logger . warn (
62+ '"variant" flag is deprecated and will be removed in future release. Please switch to "mode" flag.' ,
63+ ) ;
64+ }
5765
5866 try {
5967 if ( ! args . binaryPath ) {
60- const tasks = args . tasks || [
61- 'install' + toPascalCase ( args . mode ?? 'debug' ) ,
62- ] ;
63- let gradleArgs = getTaskNames ( androidProject . appName , tasks ) ;
68+ let gradleArgs = getTaskNames ( androidProject . appName , args , 'install' ) ;
6469
6570 if ( args . extraParams ) {
6671 gradleArgs = [ ...gradleArgs , ...args . extraParams ] ;
You can’t perform that action at this time.
0 commit comments