@@ -26,26 +26,27 @@ const LOOKUPS: Record<string, {
2626 }
2727 } ,
2828 pwsh : {
29- cmd : 'powershell ' ,
30- args : [ '-NoProfile' , '-Command' , 'Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Compress' ] ,
29+ cmd : 'pwsh ' ,
30+ args : [ '-NoProfile' , '-Command' , '" Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Compress" ' ] ,
3131 parse ( stdout : string ) {
3232 let arr : any [ ] = [ ]
3333 try {
3434 arr = JSON . parse ( stdout )
3535 } catch {
3636 return [ ]
3737 }
38+
3839 // Reshape into Ingrid-like objects for normalizeOutput
3940 return arr . map ( p => ( {
40- ProcessId : [ p . ProcessId ] ,
41- ParentProcessId : [ p . ParentProcessId ] ,
41+ ProcessId : [ p . ProcessId + '' ] ,
42+ ParentProcessId : [ p . ParentProcessId + '' ] ,
4243 CommandLine : p . CommandLine ? [ p . CommandLine ] : [ ] ,
4344 } ) )
4445 } ,
4546 } ,
4647}
4748
48- const isBin = ( f : string ) : boolean => {
49+ const isBin = ( f : string ) : boolean => {
4950 if ( f === '' ) return false
5051 if ( ! f . includes ( '/' ) && ! f . includes ( '\\' ) ) return true
5152 if ( f . length > 3 && f [ 0 ] === '"' )
@@ -309,15 +310,10 @@ export const kill = (pid: string | number, opts?: TPsNext | TPsKillOptions | TPs
309310 return promise
310311}
311312
312- export const parseGrid = ( output : string ) =>
313- output
314- ? normalizeOutput ( parse ( output , { format : IS_WIN ? 'win' : 'unix' } ) )
315- : [ ]
316-
317313export const normalizeOutput = ( data : TIngridResponse ) : TPsLookupEntry [ ] =>
318314 data . reduce < TPsLookupEntry [ ] > ( ( m , d ) => {
319- const pid = d . PID ?. [ 0 ] || d . ProcessId ?. [ 0 ]
320- const ppid = d . PPID ?. [ 0 ] || d . ParentProcessId ?. [ 0 ]
315+ const pid = ( d . PID || d . ProcessId ) ?. [ 0 ]
316+ const ppid = ( d . PPID || d . ParentProcessId ) ?. [ 0 ]
321317 const _cmd = d . CMD || d . CommandLine || d . COMMAND || [ ]
322318 const cmd = _cmd . length === 1 ? _cmd [ 0 ] . split ( / \s + / ) : _cmd
323319
0 commit comments