❌Move dependencies installations to code.sh
This commit is contained in:
parent
24bee9729c
commit
88497925f1
@ -107,74 +107,3 @@ ql repo https://github.com/Aaron-lv/sync.git "jd_cfd" "" "" "jd_scripts"
|
||||
## 口袋书店
|
||||
## ql raw https://raw.githubusercontent.com/Wenmoux/scripts/wen/jd/chinnkarahoi_jd_bookshop.js
|
||||
ql repo https://github.com/Wenmoux/scripts.git "chinnkarahoi_jd_bookshop" "" "" "wen"
|
||||
|
||||
|
||||
# 依赖
|
||||
package_name="canvas png-js date-fns axios crypto-js ts-md5 tslib @types/node dotenv"
|
||||
|
||||
install_dependencies_normal(){
|
||||
for i in $@; do
|
||||
case $i in
|
||||
canvas)
|
||||
if [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
apk add --no-cache build-base g++ cairo-dev pango-dev giflib-dev && npm install $i --build-from-source
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]]; then
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
fi
|
||||
npm i $i -g
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies_force(){
|
||||
for i in $@; do
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
rm -rf /ql/scripts/node_modules/$i
|
||||
rm -rf /ql/scripts/node_modules/lodash
|
||||
elif [[ "$(npm ls $i -g)" =~ $i ]]; then
|
||||
npm uninstall -g $i
|
||||
rm -rf /usr/local/lib/node_modules/$i
|
||||
rm -rf /usr/local/lib/node_modules/lodash
|
||||
fi
|
||||
case $i in
|
||||
canvas)
|
||||
if [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
apk add --no-cache build-base g++ cairo-dev pango-dev giflib-dev && npm install $i --build-from-source
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]]; then
|
||||
if [[ "$(npm ls $i)" =~ $i ]]; then
|
||||
npm uninstall $i
|
||||
fi
|
||||
npm i $i -g
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies_all(){
|
||||
install_dependencies_normal $package_name
|
||||
for i in $package_name; do
|
||||
if [[ "$(npm ls $i -g)" =~ (empty) ]] && [[ "$(npm ls $i)" =~ (empty) ]]; then
|
||||
install_dependencies_force $i
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
install_dependencies_all &
|
||||
|
||||
:<<!EOF!
|
||||
1、解决 JDHelloWorld 的 ts 脚本依赖问题;
|
||||
2、解决宠汪汪的依赖问题;
|
||||
3、解决京东图形验证签到的依赖问题;
|
||||
4、检测依赖包的安装状态判断是否安装依赖。安全可靠,也避免重复安装依赖导致报错。
|
||||
!EOF!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user