diff --git a/install.ps1 b/install.ps1 index 7a5af5bf..752ac2ec 100644 --- a/install.ps1 +++ b/install.ps1 @@ -34,5 +34,20 @@ while ($true) { $scriptDir = Split-Path -Parent $scriptPath $installerScript = Join-Path -Path (Join-Path -Path $scriptDir -ChildPath 'scripts') -ChildPath 'install-apply.js' +# Auto-install Node dependencies when running from a git clone +$nodeModules = Join-Path -Path $scriptDir -ChildPath 'node_modules' +if (-not (Test-Path -LiteralPath $nodeModules)) { + Write-Host '[ECC] Installing dependencies...' + Push-Location $scriptDir + try { + & npm install --no-audit --no-fund --loglevel=error + if ($LASTEXITCODE -ne 0) { + Write-Error "npm install failed with exit code $LASTEXITCODE" + exit $LASTEXITCODE + } + } + finally { Pop-Location } +} + & node $installerScript @args exit $LASTEXITCODE diff --git a/install.sh b/install.sh index d0abc14f..31925dde 100755 --- a/install.sh +++ b/install.sh @@ -14,4 +14,10 @@ while [ -L "$SCRIPT_PATH" ]; do done SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" +# Auto-install Node dependencies when running from a git clone +if [ ! -d "$SCRIPT_DIR/node_modules" ]; then + echo "[ECC] Installing dependencies..." + (cd "$SCRIPT_DIR" && npm install --no-audit --no-fund --loglevel=error) +fi + exec node "$SCRIPT_DIR/scripts/install-apply.js" "$@"