-
Notifications
You must be signed in to change notification settings - Fork 905
/
Copy pathrunPackager.ts
33 lines (31 loc) · 969 Bytes
/
runPackager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {isPackagerRunning, logger} from '@react-native-community/cli-tools';
import {startServerInNewWindow} from './startServerInNewWindow';
export async function runPackager(
port: number,
root: string,
reactNativePath: string,
terminal?: string,
packager?: boolean,
) {
if (!packager) {
return;
}
const result = await isPackagerRunning(port);
if (result === 'running') {
logger.info('JS server already running.');
} else if (result === 'unrecognized') {
logger.warn('JS server not recognized, continuing with build...');
} else {
// result == 'not_running'
logger.info('Starting JS server...');
try {
startServerInNewWindow(port, root, reactNativePath, terminal);
} catch (error) {
if (error instanceof Error) {
logger.warn(
`Failed to automatically start the packager server. Please run "react-native start" manually. Error details: ${error.message}`,
);
}
}
}
}