build.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. MOD_NAME="fe-helper"
  3. #把需要的文件都copy到相应的目录下
  4. rm -rf output && mkdir output
  5. cp -r static output/
  6. cp -r _locales output/
  7. cp online.manifest.json output/manifest.json
  8. #下载fcp代码,开始编译
  9. rm -rf fcp*
  10. cp /Users/zhaoxianlie/sourceCode/fcp/release/fcp.tar.gz . > /dev/null
  11. tar zxf fcp.tar.gz > /dev/null
  12. php fcp/index.php $MOD_NAME
  13. #如果有错,则没有产物
  14. if [[ -f "fcp/error.log" ]];then
  15. rm -rf fcp*
  16. rm -rf output
  17. exit 1;
  18. fi
  19. rm -rf fcp*
  20. #删掉svn目录
  21. cd output
  22. find . -type d -name ".svn" | xargs rm -rf
  23. rm -rf static.uncompress
  24. cd ../ && mv output $MOD_NAME && mkdir output && mv $MOD_NAME output
  25. # 扫描所有的文件
  26. function scandir(){
  27. for f in $(ls $1) ;do
  28. abspath=$1"/"$f
  29. if [[ -d $abspath ]];then
  30. scandir $abspath
  31. elif [[ -f $abspath ]];then
  32. echo $abspath
  33. fi
  34. done
  35. }
  36. # 冗余文件清理
  37. cd output/fe-helper
  38. rootpath=$(pwd)
  39. cd static
  40. # 待清理的目录
  41. cleandir="js css img"
  42. for d in $cleandir;do
  43. thefiles=$(scandir $d)
  44. for f in $thefiles;do
  45. result=$(grep $f -rl $rootpath)
  46. if [[ x"$result" == x ]];then
  47. rm -f $f
  48. echo "清理文件成功:static/$f"
  49. fi
  50. done
  51. done
  52. #生成zip包
  53. cd $rootpath/../
  54. zip -r $MOD_NAME.zip $MOD_NAME/ > /dev/null
  55. echo ""
  56. echo "生成压缩包成功,可发布到Chrome web store了!"