-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6757fca
commit ce06cf1
Showing
4 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Razor/src/Microsoft.AspNetCore.Razor.VSCode/src/BlazorDebug/Events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import { exec } from 'child_process'; | ||
import * as psList from 'ps-list'; | ||
import { DebugSession } from 'vscode'; | ||
|
||
import { RazorLogger } from '../RazorLogger'; | ||
|
||
export async function onDidTerminateDebugSession( | ||
event: DebugSession, | ||
logger: RazorLogger, | ||
) { | ||
logger.logVerbose('Terminating debugging session...'); | ||
if (process.platform !== 'win32') { | ||
try { | ||
const processes = await psList(); | ||
const devserver = processes.find( | ||
(process: psList.ProcessDescriptor) => | ||
!!(process && process.cmd && process.cmd.includes('blazor-devserver')), | ||
); | ||
if (devserver) { | ||
const command = `kill ${devserver.pid}`; | ||
exec(command, (error) => { | ||
if (error) { | ||
logger.logError( | ||
'[DEBUGGER] Error during debug process clean-up: ', | ||
error, | ||
); | ||
} | ||
return logger.logVerbose( | ||
'[DEBUGGER] Debug process clean-up complete.', | ||
); | ||
}); | ||
} | ||
} catch (error) { | ||
logger.logError('Error retrieving processes to clean-up: ', error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters