mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53202 Changelog: [internal] Just a minor refactor to follow the convention of prefixing Fantom-related globals and environment variables. Reviewed By: rshest Differential Revision: D79804007 fbshipit-source-id: 0c9a57c1b08ae18ae03cd66d1a6ef9690e0dea42
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
import type {RunServerResult} from 'metro';
|
|
|
|
type MetroServer = $NonMaybeType<RunServerResult?.['httpServer']>;
|
|
|
|
declare var __FANTOM_METRO_SERVER__: ?RunServerResult;
|
|
|
|
function getMetroServer(): ?MetroServer {
|
|
return typeof __FANTOM_METRO_SERVER__ !== 'undefined' &&
|
|
__FANTOM_METRO_SERVER__ != null
|
|
? __FANTOM_METRO_SERVER__.httpServer
|
|
: null;
|
|
}
|
|
|
|
export default async function globalTeardown(
|
|
globalConfig: {...},
|
|
projectConfig: {...},
|
|
): Promise<void> {
|
|
const metroServer = getMetroServer();
|
|
if (metroServer) {
|
|
await stopMetroServer(metroServer);
|
|
}
|
|
}
|
|
|
|
async function stopMetroServer(metroServer: MetroServer): Promise<void> {
|
|
return new Promise((resolve, reject) => {
|
|
metroServer.close(error => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|