Skip to content

Commit 12e598a

Browse files
Refactor watchMode color options
1 parent c41f131 commit 12e598a

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

packages/cli-plugin-metro/src/commands/start/watchMode.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ function enableWatchMode(messageSocket: any, ctx: Config) {
4141
}
4242
});
4343

44+
const execaOptions = {
45+
env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'},
46+
};
47+
4448
const onPress = (key: string) => {
4549
switch (key) {
4650
case 'r':
@@ -53,21 +57,27 @@ function enableWatchMode(messageSocket: any, ctx: Config) {
5357
break;
5458
case 'i':
5559
logger.info('Opening app on iOS...');
56-
execa('npx', [
57-
'react-native',
58-
'run-ios',
59-
...(ctx.project.ios?.watchModeCommandParams ?? []),
60-
{env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'}},
61-
]).stdout?.pipe(process.stdout);
60+
execa(
61+
'npx',
62+
[
63+
'react-native',
64+
'run-ios',
65+
...(ctx.project.ios?.watchModeCommandParams ?? []),
66+
],
67+
execaOptions,
68+
).stdout?.pipe(process.stdout);
6269
break;
6370
case 'a':
6471
logger.info('Opening app on Android...');
65-
execa('npx', [
66-
'react-native',
67-
'run-android',
68-
...(ctx.project.android?.watchModeCommandParams ?? []),
69-
{env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'}},
70-
]).stdout?.pipe(process.stdout);
72+
execa(
73+
'npx',
74+
[
75+
'react-native',
76+
'run-android',
77+
...(ctx.project.android?.watchModeCommandParams ?? []),
78+
],
79+
execaOptions,
80+
).stdout?.pipe(process.stdout);
7181
break;
7282
case CTRL_Z:
7383
process.emit('SIGTSTP', 'SIGTSTP');

0 commit comments

Comments
 (0)