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

fix: show killport command when port in use #10403

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vscode-extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
"teamstoolkit.localDebug.m365TenantHintMessage": "Please note that after you enrolled your developer tenant in Office 365 Target Release, it may take couple days for the enrollment to take effect. Please click 'Learn More' button for more information about setting up dev environment for extending Teams apps across Microsoft 365.",
"teamstoolkit.localDebug.npmInstallFailedHintMessage": "Task '%s' failed. Please refer to the '%s' terminal window for detailed error information or click 'Report Issue' button to report the issue.",
"teamstoolkit.localDebug.openSettings": "Open Settings",
"teamstoolkit.localDebug.portAlreadyInUse": "Port: %s is already in use. Close this port and try again.",
"teamstoolkit.localDebug.portsAlreadyInUse": "Ports: %s are already in use. Close these ports and try again.",
"teamstoolkit.localDebug.portAlreadyInUse": "Port: %s is already in use. Close this port and try again. (Open terminal and execute command `%s` to kill the port)",
"teamstoolkit.localDebug.portsAlreadyInUse": "Ports: %s are already in use. Close these ports and try again. (Open terminal and execute command `%s` to kill those ports)",
"teamstoolkit.localDebug.portWarning": "Changing port(s) in package.json may break debug. Ensure all port changes are expected or refer to documentation by clicking `Learn More` button. (%s package.json location: %s)",
"teamstoolkit.localDebug.prerequisitesCheckFailure": "Prerequisites Check Failed. If you wish to bypass checking and installing any prerequisites, you can disable them in Visual Studio Code settings.",
"teamstoolkit.localDebug.prerequisitesCheckTaskFailure": "Validate & install prerequisites failed.",
Expand Down
8 changes: 6 additions & 2 deletions packages/vscode-extension/src/debug/prerequisitesHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,19 @@ async function checkPort(
const portsInUse = await localEnvManager.getPortsInUse(ports);
const formatPortStr = (ports: number[]) =>
ports.length > 1 ? ports.join(", ") : `${ports[0]}`;
const formatPortCmd = (ports: number[]) =>
ports.length > 1 ? `npx kill-port ${ports.join(" ")}` : `npx kill-port ${ports[0]}`;
if (portsInUse.length > 0) {
ctx.properties[TelemetryProperty.DebugPortsInUse] = JSON.stringify(portsInUse);
const message = util.format(
getDefaultString("teamstoolkit.localDebug.portsAlreadyInUse"),
formatPortStr(portsInUse)
formatPortStr(portsInUse),
formatPortCmd(portsInUse)
);
const displayMessage = util.format(
localize("teamstoolkit.localDebug.portsAlreadyInUse"),
formatPortStr(portsInUse)
formatPortStr(portsInUse),
formatPortCmd(portsInUse)
);

return {
Expand Down
Loading