@@ -13,8 +13,8 @@ export class Terminal {
1313 public static launchInTerminal (
1414 dir : string ,
1515 args : string [ ] ,
16- envVars : { [ key : string ] : string }
17- ) : Promise < CP . ChildProcess > {
16+ envVars : { [ key : string ] : string | undefined }
17+ ) : Promise < CP . ChildProcess | undefined > {
1818 return this . terminalService ( ) . launchInTerminal ( dir , args , envVars )
1919 }
2020
@@ -46,29 +46,29 @@ export class Terminal {
4646}
4747
4848interface ITerminalService {
49- launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess >
49+ launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string | undefined } ) : Promise < CP . ChildProcess | undefined >
5050 killTree ( pid : number ) : Promise < any >
5151 isOnPath ( program : string ) : boolean
5252}
5353
5454class DefaultTerminalService implements ITerminalService {
5555 protected static TERMINAL_TITLE = 'VS Code Console'
5656
57- public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess > {
57+ public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess | undefined > {
5858 throw new Error ( 'launchInTerminal not implemented' )
5959 }
6060
6161 public killTree ( pid : number ) : Promise < any > {
6262 // on linux and OS X we kill all direct and indirect child processes as well
6363
64- return new Promise < any > ( ( resolve , reject ) => {
64+ return new Promise < any | void > ( ( resolve , reject ) => {
6565 try {
6666 const cmd = Path . join ( __dirname , './terminateProcess.sh' )
6767 const result = ( < any > CP ) . spawnSync ( cmd , [ pid . toString ( ) ] )
6868 if ( result . error ) {
6969 reject ( result . error )
7070 } else {
71- resolve ( )
71+ resolve ( undefined )
7272 }
7373 } catch ( err ) {
7474 reject ( err )
@@ -100,8 +100,8 @@ class DefaultTerminalService implements ITerminalService {
100100class WindowsTerminalService extends DefaultTerminalService {
101101 private static CMD = 'cmd.exe'
102102
103- public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess > {
104- return new Promise < CP . ChildProcess > ( ( resolve , reject ) => {
103+ public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess | undefined > {
104+ return new Promise < CP . ChildProcess | undefined > ( ( resolve , reject ) => {
105105 const title = `"${ dir } - ${ WindowsTerminalService . TERMINAL_TITLE } "`
106106 const command = `""${ args . join ( '" "' ) } " & pause"` // use '|' to only pause on non-zero exit code
107107
@@ -127,11 +127,11 @@ class WindowsTerminalService extends DefaultTerminalService {
127127 // when killing a process in Windows its child processes are *not* killed but become root processes.
128128 // Therefore we use TASKKILL.EXE
129129
130- return new Promise < any > ( ( resolve , reject ) => {
130+ return new Promise < any | void > ( ( resolve , reject ) => {
131131 const cmd = `taskkill /F /T /PID ${ pid } `
132132 try {
133133 CP . execSync ( cmd )
134- resolve ( )
134+ resolve ( undefined )
135135 } catch ( err ) {
136136 reject ( err )
137137 }
@@ -143,8 +143,8 @@ class LinuxTerminalService extends DefaultTerminalService {
143143 private static LINUX_TERM = '/usr/bin/gnome-terminal' // private const string LINUX_TERM = "/usr/bin/x-terminal-emulator";
144144 private static WAIT_MESSAGE = 'Press any key to continue...'
145145
146- public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess > {
147- return new Promise < CP . ChildProcess > ( ( resolve , reject ) => {
146+ public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess | undefined > {
147+ return new Promise < CP . ChildProcess | undefined > ( ( resolve , reject ) => {
148148 if ( ! FS . existsSync ( LinuxTerminalService . LINUX_TERM ) ) {
149149 reject (
150150 new Error (
@@ -181,7 +181,7 @@ class LinuxTerminalService extends DefaultTerminalService {
181181 cmd . on ( 'exit' , ( code : number ) => {
182182 if ( code === 0 ) {
183183 // OK
184- resolve ( ) // since cmd is not the terminal process but just a launcher, we do not pass it in the resolve to the caller
184+ resolve ( undefined ) // since cmd is not the terminal process but just a launcher, we do not pass it in the resolve to the caller
185185 } else {
186186 reject ( new Error ( 'exit code: ' + code ) )
187187 }
@@ -193,8 +193,8 @@ class LinuxTerminalService extends DefaultTerminalService {
193193class MacTerminalService extends DefaultTerminalService {
194194 private static OSASCRIPT = '/usr/bin/osascript' // osascript is the AppleScript interpreter on OS X
195195
196- public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess > {
197- return new Promise < CP . ChildProcess > ( ( resolve , reject ) => {
196+ public launchInTerminal ( dir : string , args : string [ ] , envVars : { [ key : string ] : string } ) : Promise < CP . ChildProcess | undefined > {
197+ return new Promise < CP . ChildProcess | undefined > ( ( resolve , reject ) => {
198198 // first fix the PATH so that 'runtimePath' can be found if installed with 'brew'
199199 // Utilities.FixPathOnOSX();
200200
@@ -230,7 +230,7 @@ class MacTerminalService extends DefaultTerminalService {
230230 osa . on ( 'exit' , ( code : number ) => {
231231 if ( code === 0 ) {
232232 // OK
233- resolve ( ) // since cmd is not the terminal process but just the osa tool, we do not pass it in the resolve to the caller
233+ resolve ( undefined ) // since cmd is not the terminal process but just the osa tool, we do not pass it in the resolve to the caller
234234 } else {
235235 if ( stderr ) {
236236 reject ( new Error ( stderr ) )
@@ -247,7 +247,7 @@ class MacTerminalService extends DefaultTerminalService {
247247
248248function extendObject < T > ( objectCopy : T , object : T ) : T {
249249 for ( let key in object ) {
250- if ( object . hasOwnProperty ( key ) ) {
250+ if ( Object . prototype . hasOwnProperty . call ( object , key ) ) {
251251 ; ( < any > objectCopy ) [ key ] = ( < any > object ) [ key ]
252252 }
253253 }
0 commit comments