@@ -12,6 +12,8 @@ import { ExecutionResult, ObservableExecutionResult, Output, ShellOptions, Spawn
12
12
import { noop } from '../utils/misc' ;
13
13
import { decodeBuffer } from './decoder' ;
14
14
import { traceVerbose } from '../../logging' ;
15
+ import { WorkspaceService } from '../application/workspace' ;
16
+ import { ProcessLogger } from './logger' ;
15
17
16
18
const PS_ERROR_SCREEN_BOGUS = / y o u r [ 0 - 9 ] + x [ 0 - 9 ] + s c r e e n s i z e i s b o g u s \. e x p e c t t r o u b l e / ;
17
19
@@ -49,12 +51,16 @@ function getDefaultOptions<T extends ShellOptions | SpawnOptions>(options: T, de
49
51
50
52
export function shellExec (
51
53
command : string ,
52
- options : ShellOptions = { } ,
54
+ options : ShellOptions & { doNotLog ?: boolean } = { } ,
53
55
defaultEnv ?: EnvironmentVariables ,
54
56
disposables ?: Set < IDisposable > ,
55
57
) : Promise < ExecutionResult < string > > {
56
58
const shellOptions = getDefaultOptions ( options , defaultEnv ) ;
57
59
traceVerbose ( `Shell Exec: ${ command } with options: ${ JSON . stringify ( shellOptions , null , 4 ) } ` ) ;
60
+ if ( ! options . doNotLog ) {
61
+ const processLogger = new ProcessLogger ( new WorkspaceService ( ) ) ;
62
+ processLogger . logProcess ( command , undefined , shellOptions ) ;
63
+ }
58
64
return new Promise ( ( resolve , reject ) => {
59
65
// eslint-disable-next-line @typescript-eslint/no-explicit-any
60
66
const callback = ( e : any , stdout : any , stderr : any ) => {
@@ -90,12 +96,16 @@ export function shellExec(
90
96
export function plainExec (
91
97
file : string ,
92
98
args : string [ ] ,
93
- options : SpawnOptions = { } ,
99
+ options : SpawnOptions & { doNotLog ?: boolean } = { } ,
94
100
defaultEnv ?: EnvironmentVariables ,
95
101
disposables ?: Set < IDisposable > ,
96
102
) : Promise < ExecutionResult < string > > {
97
103
const spawnOptions = getDefaultOptions ( options , defaultEnv ) ;
98
104
const encoding = spawnOptions . encoding ? spawnOptions . encoding : 'utf8' ;
105
+ if ( ! options . doNotLog ) {
106
+ const processLogger = new ProcessLogger ( new WorkspaceService ( ) ) ;
107
+ processLogger . logProcess ( file , args , options ) ;
108
+ }
99
109
const proc = spawn ( file , args , spawnOptions ) ;
100
110
// Listen to these errors (unhandled errors in streams tears down the process).
101
111
// Errors will be bubbled up to the `error` event in `proc`, hence no need to log.
@@ -192,12 +202,16 @@ function removeCondaRunMarkers(out: string) {
192
202
export function execObservable (
193
203
file : string ,
194
204
args : string [ ] ,
195
- options : SpawnOptions = { } ,
205
+ options : SpawnOptions & { doNotLog ?: boolean } = { } ,
196
206
defaultEnv ?: EnvironmentVariables ,
197
207
disposables ?: Set < IDisposable > ,
198
208
) : ObservableExecutionResult < string > {
199
209
const spawnOptions = getDefaultOptions ( options , defaultEnv ) ;
200
210
const encoding = spawnOptions . encoding ? spawnOptions . encoding : 'utf8' ;
211
+ if ( ! options . doNotLog ) {
212
+ const processLogger = new ProcessLogger ( new WorkspaceService ( ) ) ;
213
+ processLogger . logProcess ( file , args , options ) ;
214
+ }
201
215
const proc = spawn ( file , args , spawnOptions ) ;
202
216
let procExited = false ;
203
217
const disposable : IDisposable = {
0 commit comments