-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
32 lines (25 loc) · 940 Bytes
/
Copy pathinstall.ps1
File metadata and controls
32 lines (25 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$ErrorActionPreference = "Stop"
$appDir = if ($env:APP_DIR) { $env:APP_DIR } else { Join-Path $HOME "zhijiao-reader" }
$repoUrl = if ($env:REPO_URL) { $env:REPO_URL } else { "https://github.com/Yang-wentao/zhijiao-reader.git" }
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
throw "git is required."
}
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
throw "Node.js 20+ is required. Install it from https://nodejs.org/en/download"
}
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
throw "npm is required. Install Node.js 20+ first."
}
$nodeVersion = node -v
$nodeMajor = [int](($nodeVersion -replace '^v', '').Split('.')[0])
if ($nodeMajor -lt 20) {
throw "Node.js $nodeVersion is too old. Please upgrade to Node.js 20+."
}
if (Test-Path (Join-Path $appDir ".git")) {
git -C $appDir pull --ff-only
} else {
git clone $repoUrl $appDir
}
Set-Location $appDir
npm install
npm run launch