Skip to content
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

Merged
merged 9 commits into from
May 30, 2019
Merged

Conversation

mhartington
Copy link
Member

Adds support or multiple port forwarding.

Needed for ionic-team/ionic-cli#3995

@@ -10,11 +10,12 @@ export async function run(args: string[]) {
return;
}

let cmd: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous...


if (forwardedPorts && forwardedPorts.length > 0) {
forwardedPorts.forEach((port: string) => {
const [ device, host ] = port.split(':');
Copy link
Contributor

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?


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');
Copy link
Contributor

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.

@@ -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) => {
Copy link
Contributor

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.

@@ -50,7 +58,9 @@ export async function run(args: string[]) {

onBeforeExit(async () => {
if (ports) {
await unforwardPorts(sdk, device, ports);
ports.map(async (port: Ports) => {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks off

@imhoffd imhoffd merged commit 7844ea4 into master May 30, 2019
@imhoffd imhoffd deleted the feat-console-port-forwarding branch May 30, 2019 19:00
Ionitron added a commit that referenced this pull request May 30, 2019
# [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))
@Ionitron
Copy link
Collaborator

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants