-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
46 lines (41 loc) · 1.13 KB
/
deploy.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
#!/bin/bash
plugin_dir=$(pwd)
plugin_slug="$(basename $plugin_dir)"
js_dirs=("./assets/js/")
plugin_file="./${plugin_slug}.php"
task=$1
#get version
#version=$(cat ${plugin_file} | grep "Version:" | cut -d ":" -f 2 | sed -e 's/^[ \t]*//')
if [ -z "$task" ]
then
task="deploy"
fi
if [ $task = "deploy" ] || [ $task = "min" ]
then
echo "Running (min) task"
#minimize JavaScript
for js_dir in "${js_dirs[@]}"
do
rm ${js_dir}*.min.js;
for f in ${js_dir}*.js;
do short=${f%.js};
uglifyjs ${f} --compress --mangle --output ${short}.min.js;
echo "File ${short}.js minimize."
done
done
fi
if [ $task = "deploy" ] || [ $task = "pot" ]
then
echo "Running (pot) task"
#text domain
text_domain=$(cat ${plugin_file} | grep "Text Domain:" | cut -d ":" -f 2 | sed -e 's/^[ \t]*//')
#pot file.
wp i18n make-pot . languages/${text_domain}.pot
fi
if [ $task = "deploy" ] || [ $task = "zip" ]
then
echo "Running (zip) task"
#zip
cd ..
zip -r /var/www/public/${plugin_slug}.zip ${plugin_slug} -x "*node_modules/*" "*.git/*" "*deploy/*" "*deploy.sh" "*Gruntfile.js" "*readme.md" "*README.md" "*package.json" "*.gitignore" "*phpcs.xml*"
fi