mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
63 lines
2.0 KiB
Bash
Executable File
63 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SOURCE="${BASH_SOURCE[0]}"
|
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
|
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
SOURCE="$(readlink "$SOURCE")"
|
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
|
done
|
|
root_dir="$( cd -P "$( dirname "$SOURCE" )"/.. >/dev/null 2>&1 && pwd )"
|
|
|
|
# 数据目录处理
|
|
if [ -z $XDG_CONFIG_HOME ];then
|
|
DATA_DIR=$HOME/.config
|
|
else
|
|
DATA_DIR=$XDG_CONFIG_HOME
|
|
fi
|
|
|
|
# 获取App名称
|
|
APP_NAME=$( cat "$root_dir/package.nw/package.json" | grep -Eo 'name":".*","main' )
|
|
APP_NAME=${APP_NAME//name\":\"/}
|
|
APP_NAME=${APP_NAME//\",\"main/}
|
|
|
|
export WECHAT_DEVTOOLS_DIR="$root_dir/nwjs"
|
|
export APPDATA="$DATA_DIR/$APP_NAME"
|
|
export PATH="$root_dir/node/bin:$root_dir/nwjs:$PATH"
|
|
export USERPROFILE=$APPDATA
|
|
|
|
# SNAP
|
|
# if [ -n $SNAP ];then
|
|
# if [ ! -f $DATA_DIR/nacl_irt_x86_64.nexe ];then
|
|
# # 解压
|
|
# tar -zxf $root_dir/nwjs/nacl_irt_x86_64.nexe.tar.gz -C $APPDATA/nacl_irt_x86_64.nexe
|
|
# fi
|
|
# fi
|
|
|
|
clean_cache() {
|
|
echo "清理缓存";
|
|
rm -rf "$APPDATA/WeappCache";
|
|
rm -rf "$APPDATA/WeappVendor";
|
|
rm -rf "$DATA_DIR/wechat_devtools"
|
|
}
|
|
|
|
# 检测是否有清除缓存的必要
|
|
if [[ -f "$APPDATA/.build_time" ]];then
|
|
diff "$APPDATA/.build_time" "$root_dir/package.nw/.build_time" >/dev/null;
|
|
if [ ! "$?" == "0" ];then
|
|
\cp -f "$root_dir/package.nw/.build_time" "$APPDATA/.build_time";
|
|
clean_cache;
|
|
fi;
|
|
else
|
|
\cp -f "$root_dir/package.nw/.build_time" "$APPDATA/.build_time";
|
|
clean_cache;
|
|
fi;
|
|
|
|
EXTENSION1="--load-extension=$root_dir/nwjs/package.nw/js/ideplugin"
|
|
EXTENSION2=--load-extension=$APPDATA/WeappPlugin
|
|
INSPECTOR1="--custom-devtools-frontend=file://$root_dir/package.nw/js/ideplugin/inspector" # 要加file://指明为本地文件路径
|
|
INSPECTOR2="--custom-devtools-frontend=file://$APPDATA/WeappPlugin/inspector/"
|
|
USERDATADIR="$APPDATA"
|
|
|
|
# "$@"参数
|
|
LANG=zh_CN.UTF-8
|
|
exec "$root_dir/nwjs/nw" $root_dir/package.nw $EXTENSION2 $INSPECTOR1 "$@" |