-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat console port forwarding #26
Conversation
src/android/index.ts
Outdated
@@ -10,11 +10,12 @@ export async function run(args: string[]) { | |||
return; | |||
} | |||
|
|||
let cmd: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dangerous...
src/android/run.ts
Outdated
|
||
if (forwardedPorts && forwardedPorts.length > 0) { | ||
forwardedPorts.forEach((port: string) => { | ||
const [ device, host ] = port.split(':'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation looks off here, does tslint not catch this?
src/android/run.ts
Outdated
|
||
if (forwardedPorts && forwardedPorts.length > 0) { | ||
forwardedPorts.forEach((port: string) => { | ||
const [ device, host ] = port.split(':'); | ||
|
||
if (!device || !host) { | ||
throw new CLIException('Invalid --forward value: expecting <device port:host port>, e.g. 8080:8080'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that --forward
can take multiple values, it may be useful to print which values were the bad ones.
src/android/run.ts
Outdated
@@ -37,8 +42,11 @@ export async function run(args: string[]) { | |||
await waitForBoot(sdk, device); | |||
|
|||
if (ports) { | |||
await forwardPorts(sdk, device, ports); | |||
log(`Forwarded device port ${ports.device} to host port ${ports.host}\n`); | |||
ports.map(async (port: Ports) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should await Promise.all(ports.map( ... ))
so the ports are forwarded before installing the apk.
src/android/run.ts
Outdated
@@ -50,7 +58,9 @@ export async function run(args: string[]) { | |||
|
|||
onBeforeExit(async () => { | |||
if (ports) { | |||
await unforwardPorts(sdk, device, ports); | |||
ports.map(async (port: Ports) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should await Promise.all(ports.map( ... ))
or the process may exit before the ports are freed
src/utils/cli.ts
Outdated
export function getOptionsValue(args: string[], arg: string): string[] { | ||
const returnVal: string[] = []; | ||
args.map((entry: string, idx: number) => { | ||
if (entry === arg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation looks off
# [0.2.0](v0.1.2...v0.2.0) (2019-05-30) ### Bug Fixes * **ios:** log iOS --list errors, but still print ([e516a83](e516a83)) * **ios:** print more helpful error if app path doesn't exist ([49819b0](49819b0)) ### Features * **android:** better error messaging ([0cfa51a](0cfa51a)) * **android:** have --forward accept multiple values ([#26](#26)) ([7844ea4](7844ea4))
🎉 This PR is included in version 0.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Adds support or multiple port forwarding.
Needed for ionic-team/ionic-cli#3995