@@ -24,6 +24,7 @@ import { vsCommand, VsCommandError } from '../vscommand';
2424
2525import path = require( 'path' ) ;
2626import globby = require( 'globby' ) ;
27+ import treeKill = require( 'tree-kill' ) ;
2728
2829const waitPort = require ( 'wait-port' ) ;
2930
@@ -47,6 +48,13 @@ export class Component extends OpenShiftItem {
4748 ] ;
4849 }
4950
51+ static stopDebugSession ( component : OpenShiftObject ) : void {
52+ const ds = Component . debugSessions . get ( component . contextPath . fsPath ) ;
53+ if ( ds ) {
54+ treeKill ( ds . configuration . odoPid ) ;
55+ }
56+ }
57+
5058 static async getOpenshiftData ( context : OpenShiftObject ) : Promise < OpenShiftObject > {
5159 return Component . getOpenShiftCmdData ( context ,
5260 "In which Project you want to create a Component" ,
@@ -108,7 +116,9 @@ export class Component extends OpenShiftItem {
108116 if ( component . contextValue === ContextType . COMPONENT_NO_CONTEXT || component . contextValue === ContextType . COMPONENT_PUSHED ) {
109117 await Component . unlinkAllComponents ( component ) ;
110118 }
119+ Component . stopDebugSession ( component ) ;
111120 await Component . odo . deleteComponent ( component ) ;
121+
112122 } ) . then ( ( ) => `Component '${ name } ' successfully deleted` )
113123 . catch ( ( err ) => Promise . reject ( new VsCommandError ( `Failed to delete Component with error '${ err } '` ) ) ) ;
114124 }
@@ -127,6 +137,7 @@ export class Component extends OpenShiftItem {
127137 const value = await window . showWarningMessage ( `Do you want to undeploy Component '${ name } '?` , 'Yes' , 'Cancel' ) ;
128138 if ( value === 'Yes' ) {
129139 return Progress . execFunctionWithProgress ( `Undeploying the Component '${ component . getName ( ) } '` , async ( ) => {
140+ Component . stopDebugSession ( component ) ;
130141 await Component . odo . undeployComponent ( component ) ;
131142 } ) . then ( ( ) => `Component '${ name } ' successfully undeployed` )
132143 . catch ( ( err ) => Promise . reject ( new VsCommandError ( `Failed to undeploy Component with error '${ err } '` ) ) ) ;
0 commit comments