-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
142vip.cn
committed
Oct 27, 2023
1 parent
f9f1702
commit 30007d8
Showing
3 changed files
with
74 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
#!/bin/bash | ||
## | ||
## 依赖安装脚本 | ||
## 使用: | ||
## ./scripts/ci | ||
## | ||
|
||
# 期望的 pnpm 大版本号 | ||
majorVersionRequired="8" | ||
|
||
# 检测 pnpm 是否已安装并且大版本号符合要求 | ||
checkPNPMVersion() { | ||
local pnpmVersionInstalled=$(pnpm --version 2>/dev/null) # 获取已安装的 pnpm 版本 | ||
if [[ $pnpmVersionInstalled =~ ^$majorVersionRequired ]]; then | ||
echo "已安装的 pnpm 版本:$pnpmVersionInstalled" | ||
echo "已安装的 pnpm 大版本号符合要求." | ||
return 0 | ||
else | ||
echo "未安装 pnpm 或 pnpm 大版本号不符合要求." | ||
return 1 | ||
fi | ||
} | ||
|
||
# 安装pnpm | ||
installRequiredPNPM(){ | ||
npm i pnpm@$majorVersionRequired -g | ||
} | ||
|
||
|
||
## 判断是PNPM安装且版本符合要求 | ||
if command -v pnpm &> /dev/null && checkPNPMVersion; then | ||
echo "无需安装 pnpm@@$majorVersionRequired" | ||
else | ||
echo "安装 pnpm@$majorVersionRequired..." | ||
installRequiredPNPM; | ||
fi | ||
|
||
# 安装项目依赖 | ||
pnpm i --frozen-lockfile --registry https://registry.npmmirror.com | ||
|
||
## 安装依赖 | ||
npm i pnpm@8 -g && pnpm i --frozen-lockfile --registry https://registry.npmmirror.com |