MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / powershell

Function powershell

__tests__/windows-powershell-module-path.test.ts:152–162  ·  view source on GitHub ↗

Run a script in Windows PowerShell with `env`.

(script: string, env: NodeJS.ProcessEnv)

Source from the content-addressed store, hash-verified

150
151 /** Run a script in Windows PowerShell with `env`. */
152 function powershell(script: string, env: NodeJS.ProcessEnv): Promise<{ code: number; stdout: string; stderr: string }> {
153 const encoded = Buffer.from(`$ErrorActionPreference='Stop'\n$ProgressPreference='SilentlyContinue'\n${script}`, 'utf16le').toString('base64');
154 return new Promise((resolve) => {
155 execFile(
156 'powershell.exe',
157 ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', encoded],
158 { windowsHide: true, timeout: 120_000, env },
159 (err, stdout, stderr) => resolve({ code: err ? (typeof err.code === 'number' ? err.code : 1) : 0, stdout: stdout.trim(), stderr }),
160 );
161 });
162 }
163
164 /** A module newer than Windows PowerShell's own, whose one command fails. */
165 function standIn(name: string, command: string, message: string): void {

Calls 2

fromMethod · 0.80
resolveFunction · 0.70

Tested by

no test coverage detected