mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
fix(install): fail closed on unparseable Node version and make test env immutable
- Reject unparseable or empty Node.js version output before major version check - Define minimumNodeMajor constant to eliminate duplicate version numbers - Build child test environments immutably without in-place mutation - Add regression test for unparseable Node.js version output
This commit is contained in:
1 parent
018c311bcf
commit
5c78d38bab
2 files changed
+60
-19
No files matched your search
+9
-3
@@ -35,14 +35,20 @@ $scriptDir = Split-Path -Parent $scriptPath
|
||||
$installerScript = Join-Path -Path (Join-Path -Path $scriptDir -ChildPath 'scripts') -ChildPath 'install-apply.js'
|
||||
|
||||
# ponytail: preflight Node.js presence and version (>= 18)
|
||||
$minimumNodeMajor = 18
|
||||
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
|
||||
[Console]::Error.WriteLine('[ECC] Node.js is required but was not found in PATH. Please install Node.js 18 or newer: https://nodejs.org')
|
||||
[Console]::Error.WriteLine("[ECC] Node.js is required but was not found in PATH. Please install Node.js $minimumNodeMajor or newer: https://nodejs.org")
|
||||
exit 1
|
||||
}
|
||||
|
||||
$nodeVersion = (& node -v 2>$null | Select-Object -First 1)
|
||||
if ($nodeVersion -match '^\s*v?(\d+)\.' -and [int]$Matches[1] -lt 18) {
|
||||
[Console]::Error.WriteLine("[ECC] Node.js 18 or newer is required (found $nodeVersion). Please update Node.js: https://nodejs.org")
|
||||
if (-not $nodeVersion -or $nodeVersion -notmatch '^\s*v?(\d+)\.') {
|
||||
[Console]::Error.WriteLine("[ECC] Failed to determine Node.js version (found '$nodeVersion'). Node.js $minimumNodeMajor or newer is required: https://nodejs.org")
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ([int]$Matches[1] -lt $minimumNodeMajor) {
|
||||
[Console]::Error.WriteLine("[ECC] Node.js $minimumNodeMajor or newer is required (found $nodeVersion). Please update Node.js: https://nodejs.org")
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user