-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.ps1
53 lines (45 loc) · 1.09 KB
/
start.ps1
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
python -V > $null
if ($? -eq 0){
Write-Host "未找到 Python,终止运行"
pause
exit 1
}
python -c "import pip" > $null
if ($? -eq 0){
Write-Host "未找到 Python Pip 模块,终止运行"
pause
exit 1
}
python -c "import venv" > $null
if ($? -eq 0){
Write-Host "未找到 Python venv 模块,终止运行"
pause
exit 1
}
if (-not (Test-Path .\venv\Scripts\activate.ps1)) {
Write-Host "未找到虚拟环境"
Write-Host "创建虚拟环境中..."
python -m venv venv
}
.\venv\Scripts\activate.ps1
if (-not (Test-Path .\venv\Scripts\mkdocs.exe)) {
Write-Host "安装 MKDocs 中..."
python -m pip install -r requirements.txt --index-url https://mirror.baidu.com/pypi/simple
if ($? -eq 0){
Write-Host "安装 MKDocs 失败,终止运行"
pause
exit 1
}
}
switch ($args) {
"--update" {
Write-Host "更新 MKDocs 中..."
python -m pip install -r requirements.txt --upgrade --index-url https://mirror.baidu.com/pypi/simple
if ($LastExitCode -ne 0) {
Write-Host "更新 MKDocs 失败"
}
}
}
Write-Host "启动 MKDocs 中..."
mkdocs serve
Read-Host | Out-Null