1+
2+
3+ # /bin/bash
4+
5+ # if any return not equal to true, process will quit.
6+ # refer to https://www.zhizhesoft.com/unix-linux-jiao-ben-zhong-set-e-de-zuo-yong/
7+ set -e
8+
9+ # refer to https://blog.csdn.net/qq_20417499/article/details/103308076
10+ # this script's parent directory
11+ cd $( dirname $0 )
12+ parentDir=$( pwd)
13+
14+ cd dist
15+ echo " setup files ..."
16+ cp ${parentDir} /src/info.plist ./
17+ cp ${parentDir} /src/icon.png ./
18+ cp ${parentDir} /README.md ./
19+ cp ${parentDir} /LICENSE ./
20+
21+ rm ./index.mjs
22+
23+ # insert the vesion to .plist file, if you need
24+ echo " Updating version ..."
25+ curVersion=$( node -e " console.log(require('${parentDir} /package.json').version)" )
26+ sed -i ' ' ' s/{{version}}/' ${curVersion} ' /' ./info.plist
27+
28+ # insert the readme content in src dir to .plist file, if you need
29+ echo " Injecting readme ..."
30+ readme=" ${parentDir} /src/README.md"
31+ sed -i ' ' -e " /{{readme}}/{r ${readme} " -e ' d' -e ' }' ./info.plist
32+
33+ # insert the auto-update to .plist file, if you need, and you need to fill in the workflow info in that file
34+ echo " Injecting auto-update script ..."
35+ update=" $( mktemp) "
36+ # s/&/\&/g; s/</\</g; s/>/\>/g this pattern is use for repalcing '&' '<' '>'
37+ cat ${parentDir} /src/update.sh | sed ' s/&/\&/g; s/</\</g; s/>/\>/g' > ${update}
38+ sed -i ' ' -e " /{{update_script}}/{r ${update} " -e ' d' -e ' }' ./info.plist
39+
40+ echo " Bundling workflow ..."
41+ name=$( node -e " console.log(require('${parentDir} /package.json').name)" )
42+ zip -Z deflate -rq9 ${parentDir} /dist/${name} .alfredworkflow * -x etc
0 commit comments