1 Star 0 Fork 0

兴博软件/EspruinoDocs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
buildmodules.sh 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
# Copyright (c) 2013 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission.
cd `dirname $0`
DIR=`pwd`
WEBSITE="$HOME/workspace/espruinowebsite"
MODULEDIR=$WEBSITE/www/modules
mkdir -p $MODULEDIR
# Minify all modules
MODULES=`find devices modules boards -name "*.js"`
for module in $MODULES; do
if [ -f $module ]; then
echo ">>>>" $module # e.g. <module-path>/DS18B20.js
BNAME=`basename $module .js` # e.g. 'DS18B20'
MINJS=${BNAME}.min.js # e.g. 'DS18B20.min.js'
# An optional externs-file must be in the same directory as the module file.
# Example devices/.../DS18B20.js → devices/.../DS18B20.externs
externsFile="`dirname $module`/`basename -s .js $module`.externs" # e.g. <module-path>/DS18B20.externs
TARGET_MODULE="$MODULEDIR/$BNAME.js" # e.g. ~/workspace/espruinowebsite/www/modules/DS18B20.js
# do nothing if ..
# .. the module code haven't changed and
# .. the target module file is newer than an existing externs file (or the externs file does not exist)
if (diff $module $MODULEDIR/$BNAME.js >/dev/null 2>&1) && [[ (! -e $externsFile) || ($TARGET_MODULE -nt $externsFile) ]]; then
echo "Module $BNAME hasn't changed, leaving"
continue
fi
echo "Module $BNAME is different or doesn't exist"
rm -f $MODULEDIR/$MINJS
cp $module $MODULEDIR/$BNAME.js
echo min $MODULEDIR/$module to $MINJS
nodejs bin/minify.js "$MODULEDIR/$BNAME.js" "$MODULEDIR/$MINJS" "$externsFile"
if [[ -s $MODULEDIR/$MINJS ]] ; then
echo "$MODULEDIR/$MINJS compile successful"
else
rm $MODULEDIR/$BNAME.js
echo "$module compile FAILED."
exit 1
fi
fi
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lalbe/EspruinoDocs.git
git@gitee.com:lalbe/EspruinoDocs.git
lalbe
EspruinoDocs
EspruinoDocs
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385