mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
54 lines
1.1 KiB
Bash
Executable File
54 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e # 命令出错就退出
|
|
trap 'catchError $LINENO $BASH_COMMAND' SIGHUP SIGINT SIGQUIT EXIT # 捕获错误情况
|
|
|
|
catchError() {
|
|
exit_code=$?
|
|
if [ $exit_code -ne 0 ]; then
|
|
fail "\033[31mcommand: $2\n at $0:$1\n at $STEP\033[0m"
|
|
fi
|
|
exit $exit_code
|
|
}
|
|
|
|
success() {
|
|
echo -e "\033[42;37m 成功 \033[0m $1"
|
|
}
|
|
|
|
fail() {
|
|
echo -e "\033[41;37m 失败 \033[0m $1"
|
|
}
|
|
|
|
|
|
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
|
|
|
echo "==========Initializing node=========="
|
|
|
|
if [ -f "$root_dir/node/bin/node" ]; then
|
|
success "node安装完毕"
|
|
else
|
|
node "$root_dir/tools/update-node-node"
|
|
success "node ok"
|
|
fi
|
|
|
|
if [ ! -f "$root_dir/node/bin/node" ]; then
|
|
fail "Node安装失败"
|
|
exit
|
|
fi
|
|
|
|
# 将node加入环境
|
|
export PATH="$root_dir/node/bin":$PATH
|
|
|
|
echo "==========Initializing nwjs=========="
|
|
if [ -f "$root_dir/nwjs/nw" ]; then
|
|
success "nwjs安装完毕"
|
|
else
|
|
node "$root_dir/tools/update-nwjs-node"
|
|
fi
|
|
|
|
echo "==========Initializing wechat-devtools package=========="
|
|
if [ -f "$root_dir/package.nw/package.json" ]; then
|
|
success "微信开发者工具安装完毕"
|
|
else
|
|
node "$root_dir/tools/update-wechat-devtools-node"
|
|
fi |