UNPKG

1.12 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _fetch = require("./fetch");
8/**
9 * Copyright (c) Facebook, Inc. and its affiliates.
10 *
11 * This source code is licensed under the MIT license found in the
12 * LICENSE file in the root directory of this source tree.
13 *
14 */
15
16/**
17 * Indicates whether or not the packager is running. It returns a promise that
18 * returns one of these possible values:
19 * - `running`: the packager is running
20 * - `not_running`: the packager nor any process is running on the expected port.
21 * - `unrecognized`: one other process is running on the port we expect the packager to be running.
22 */
23async function isPackagerRunning(packagerPort = process.env.RCT_METRO_PORT || '8081') {
24 try {
25 const {
26 data
27 } = await (0, _fetch.fetch)(`http://localhost:${packagerPort}/status`);
28 return data === 'packager-status:running' ? 'running' : 'unrecognized';
29 } catch (_error) {
30 return 'not_running';
31 }
32}
33var _default = isPackagerRunning;
34exports.default = _default;
35
36//# sourceMappingURL=isPackagerRunning.js.map
\No newline at end of file