@pzy560117/codex-harness 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
function commandExists(command) {
|
|
4
|
+
const result = spawnSync(command, ["-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()"], {
|
|
5
|
+
stdio: "ignore",
|
|
6
|
+
windowsHide: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
return result.status === 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
export function findPowerShell() {
|
|
13
|
+
for (const candidate of ["pwsh", "powershell"]) {
|
|
14
|
+
if (commandExists(candidate)) {
|
|
15
|
+
return candidate;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
2
19
|
return "powershell";
|
|
3
20
|
}
|
|
@@ -69,7 +69,19 @@ function Add-DoctorWarning {
|
|
|
69
69
|
function Get-DoctorFileSha256 {
|
|
70
70
|
param([string]$Path)
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
$sha256 = [System.Security.Cryptography.SHA256]::Create()
|
|
73
|
+
$stream = $null
|
|
74
|
+
try {
|
|
75
|
+
$stream = [System.IO.File]::OpenRead($Path)
|
|
76
|
+
$hashBytes = $sha256.ComputeHash($stream)
|
|
77
|
+
return (($hashBytes | ForEach-Object { $_.ToString("x2") }) -join "")
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
if ($null -ne $stream) {
|
|
81
|
+
$stream.Dispose()
|
|
82
|
+
}
|
|
83
|
+
$sha256.Dispose()
|
|
84
|
+
}
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
function Test-TaskFileHasTemplatePlaceholder {
|