Files
flipper/desktop/app/src/utils/adbConfig.tsx
Mathis Gardon f25d189aa5 Support custom metro ports (#2050)
Summary:
Based on issue https://github.com/facebook/flipper/issues/1509 I needed a custom port for the metro server to pass to flipper.

## Changelog

introduce `METRO_SERVER_PORT` env variable to be able to customize default 8081 port on startup.

Pull Request resolved: https://github.com/facebook/flipper/pull/2050

Test Plan:
Tested with a locally built linux desktop app, this seems to work OK pour hermes debugging & RN logging.

React DevTools don't seem to find the running app, maybe there's a mapping to handle there too ?

Reviewed By: jknoxville

Differential Revision: D27339006

Pulled By: passy

fbshipit-source-id: b1700c4fe73f14bf4617e23583b2954012e0a5aa
2021-03-31 03:30:14 -07:00

34 lines
735 B
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {parseEnvironmentVariableAsNumber} from './environmentVariables';
export default () => {
let port = parseEnvironmentVariableAsNumber(
'ANDROID_ADB_SERVER_PORT',
5037,
) as number;
let host = 'localhost';
const socket = (process.env.ADB_SERVER_SOCKET || '').trim();
if (socket && socket.length > 0) {
const match = socket.match(/^(tcp:)(\S+):(\d+)/);
if (match && match.length === 4) {
host = match[2];
port = parseInt(match[3], 10);
}
}
return {
port,
host,
};
};