File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ export type ShellCreateOpts = {
1818export type ShellRunOpts = {
1919 ptySize ?: ShellSize ;
2020 shellName ?: string ;
21+ env ?: Record < string , string > ;
22+ cwd ?: string ;
2123} ;
2224export type ShellOpenOpts = {
2325 ptySize ?: ShellSize ;
@@ -123,8 +125,9 @@ export class Shells extends Disposable {
123125 command ,
124126 opts ?. ptySize ?? DEFAULT_SHELL_SIZE ,
125127 undefined ,
126- undefined ,
127- opts ?. shellName
128+ opts ?. env ,
129+ opts ?. shellName ,
130+ opts ?. cwd
128131 ) ;
129132
130133 return shell ;
@@ -287,7 +290,8 @@ function runCommandAsUser(
287290 shellSize : ShellSize = DEFAULT_SHELL_SIZE ,
288291 runPreCommand ?: ( ) => Promise < void > ,
289292 env ?: Record < string , string > ,
290- shellName ?: string
293+ shellName ?: string ,
294+ cwd ?: string
291295) : RunningCommand {
292296 const disposableStore = new DisposableStore ( ) ;
293297 const onOutput = new Emitter < string > ( ) ;
@@ -300,10 +304,15 @@ function runCommandAsUser(
300304 await runPreCommand ( ) ;
301305 }
302306
303- const commandWithEnv = `env ${ Object . entries ( env ?? { } )
307+ // TODO: use a new shell API that natively supports cwd & env
308+ let commandWithEnv = `env ${ Object . entries ( env ?? { } )
304309 . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
305310 . join ( " " ) } ${ command } `;
306311
312+ if ( cwd ) {
313+ commandWithEnv = `cd ${ cwd } && ${ commandWithEnv } ` ;
314+ }
315+
307316 shell = await pitcher . clients . shell . create (
308317 pitcher . workspacePath ,
309318 shellSize ,
You can’t perform that action at this time.
0 commit comments