forked from xdmjun/wxappUnpacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onekey.sh
66 lines (57 loc) · 1.41 KB
/
onekey.sh
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
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# author:xuedingmiaojun
# site:xuedingmiao.com
# MyWxappUnpacker 项目路径
WXAPPUNPACKER_PATH=`pwd`
FILE_FORMAT=wxapkg
wxappUnpacker_pkg() {
echo "node ${WXAPPUNPACKER_PATH}/wuWxapkg.js ${fname} $main_pkg"
node ${WXAPPUNPACKER_PATH}/wuWxapkg.js $main_pkg ${fname}
return 0;
}
wxappUnpacker() {
folder_name=$main_pkg
de_dir=$dir
if [ -z "$dir" ]
then de_dir=`pwd`
fi
for fname in `find ${de_dir} -name "*.${FILE_FORMAT}"`
do
file_name=${fname##*/};
echo "分包:${file_name}";
short_name=${file_name%*.wxapkg};
folder=${folder_name##*/};
if [ $short_name != $folder ]
then
# 子包目录如果存在就先删除
subpackage_path=${fname%*.wxapkg}
if [ -d $subpackage_path ]
then rm -rf $subpackage_path
fi
wxappUnpacker_pkg ${file_name} $main_pkg
fi
done
return 0;
}
de_pkg() {
dir=`dirname $1`
tmp_pkg=$1
path=${tmp_pkg%%.wxapkg}
main_pkg="-s=${path}"
echo "包文件存放目录:${dir}"
# 判断主包是否已经解开
order=$main_pkg
folder_name=${order##*=}
echo "主包目录:${folder_name}"
# 没解主包时先解主包
if [ ! -d $folder_name ]
then
echo "主包名:${folder_name}.wxapkg"
node wuWxapkg.js "${folder_name}.wxapkg"
fi
# 解分包
wxappUnpacker $dir $main_pkg
return 0;
}
# $1: main pkg file
de_pkg $1