Skip to content

Commit 40a4658

Browse files
committed
fix: show killport command when port in use
1 parent e662467 commit 40a4658

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/vscode-extension/package.nls.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@
231231
"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.",
232232
"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.",
233233
"teamstoolkit.localDebug.openSettings": "Open Settings",
234-
"teamstoolkit.localDebug.portAlreadyInUse": "Port: %s is already in use. Close this port and try again.",
235-
"teamstoolkit.localDebug.portsAlreadyInUse": "Ports: %s are already in use. Close these ports and try again.",
234+
"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)",
235+
"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)",
236236
"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)",
237237
"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.",
238238
"teamstoolkit.localDebug.prerequisitesCheckTaskFailure": "Validate & install prerequisites failed.",

packages/vscode-extension/src/debug/prerequisitesHandler.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,19 @@ async function checkPort(
182182
const portsInUse = await localEnvManager.getPortsInUse(ports);
183183
const formatPortStr = (ports: number[]) =>
184184
ports.length > 1 ? ports.join(", ") : `${ports[0]}`;
185+
const formatPortCmd = (ports: number[]) =>
186+
ports.length > 1 ? `npx kill-port ${ports.join(" ")}` : `npx kill-port ${ports[0]}`;
185187
if (portsInUse.length > 0) {
186188
ctx.properties[TelemetryProperty.DebugPortsInUse] = JSON.stringify(portsInUse);
187189
const message = util.format(
188190
getDefaultString("teamstoolkit.localDebug.portsAlreadyInUse"),
189-
formatPortStr(portsInUse)
191+
formatPortStr(portsInUse),
192+
formatPortCmd(portsInUse)
190193
);
191194
const displayMessage = util.format(
192195
localize("teamstoolkit.localDebug.portsAlreadyInUse"),
193-
formatPortStr(portsInUse)
196+
formatPortStr(portsInUse),
197+
formatPortCmd(portsInUse)
194198
);
195199

196200
return {

0 commit comments

Comments
 (0)