microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
improve-cdp-message

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/commands/killPort.ts

33lines · modeblame

f1cb0a40lexie0111 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as assert from "assert";
5import * as vscode from "vscode";
6import { ErrorHelper } from "../../common/error/errorHelper";
7import { InternalErrorCode } from "../../common/error/internalErrorCode";
8import { ChildProcess } from "../../common/node/childProcess";
9import { OutputChannelLogger } from "../log/OutputChannelLogger";
10import { wait } from "../../common/utils";
7a4506dclexie0111 years ago11import { ReactNativeCommand } from "./util/reactNativeCommand";
f1cb0a40lexie0111 years ago12
13const logger = OutputChannelLogger.getMainChannel();
14export class killPort extends ReactNativeCommand {
15codeName = "killPort";
16label = "Kill Port";
17error = ErrorHelper.getInternalError(InternalErrorCode.FailedToKillPort);
18
19async baseFn(): Promise<void> {
20assert(this.project);
21await wait();
22await vscode.window
23.showInputBox({ placeHolder: "please enter the port you want to kill" })
24.then(async value => {
25if (value) {
26const res = await new ChildProcess().exec(`npx kill-port ${value}`);
27logger.info(`killing port ${value}, it may take a while...`);
28const outcome = await res.outcome;
29logger.info(outcome);
30}
31});
32}
33}