/**
 * 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.
 *
 */ import { execFileSync } from 'child_process' ; import { logger } from '@react-native-community/cli-tools' ; import getAdbPath from './getAdbPath' ; function tryRunAdbReverse ( packagerPort , device ? ) { try { const adbPath = getAdbPath ( ) ; const adbArgs = [ 'reverse' , `tcp:${ packagerPort }` , `tcp:${ packagerPort }` ] ; if ( device ) { adbArgs . unshift ( '-s' , device ) ; } logger . info ( 'Connecting to the development server...' ) ; logger . debug ( `Running command "${ adbPath } ${ adbArgs . join ( ' ' ) }"` ) ; execFileSync ( adbPath , adbArgs , { stdio : 'inherit' } ) ; } catch ( e ) { logger . warn ( `Failed to connect to development server using "adb reverse": ${ e . message }` ) ; } } export default tryRunAdbReverse ;