microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix-ts-error1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/commands/killPort.ts

33lines · modecode

1// 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";
11import { ReactNativeCommand } from "./util/reactNativeCommand";
12
13const logger = OutputChannelLogger.getMainChannel();
14export class killPort extends ReactNativeCommand {
15 codeName = "killPort";
16 label = "Kill Port";
17 error = ErrorHelper.getInternalError(InternalErrorCode.FailedToKillPort);
18
19 async baseFn(): Promise<void> {
20 assert(this.project);
21 await wait();
22 await vscode.window
23 .showInputBox({ placeHolder: "please enter the port you want to kill" })
24 .then(async value => {
25 if (value) {
26 const res = await new ChildProcess().exec(`npx kill-port ${value}`);
27 logger.info(`killing port ${value}, it may take a while...`);
28 const outcome = await res.outcome;
29 logger.info(outcome);
30 }
31 });
32 }
33}
34