2017-11-06 14:02:51 +00:00
|
|
|
#!/bin/bash
|
2017-10-20 14:30:04 +00:00
|
|
|
|
2017-11-06 14:02:51 +00:00
|
|
|
source build-config.cfg
|
2017-10-20 14:30:04 +00:00
|
|
|
|
2017-12-04 18:34:47 +00:00
|
|
|
## Only run npm build if there was a change in a .js or .vue file
|
2018-01-29 17:24:51 +00:00
|
|
|
current_md5_js=$(<last-js-build.md5)
|
|
|
|
current_md5_sass=$(<last-sass-build.md5)
|
|
|
|
current_md5_composer=$(<last-composer-build.md5)
|
|
|
|
current_md5_package=$(<last-package-build.md5)
|
|
|
|
|
2018-01-22 11:48:51 +00:00
|
|
|
current_OS=`uname`
|
|
|
|
|
|
|
|
# For macOS (Darwin)
|
|
|
|
if [ $current_OS == "Darwin" ]; then
|
2018-01-29 17:24:51 +00:00
|
|
|
find src -type f \( -name "*.js" -or -name "*.vue" \) -exec md5 {} \; | sort -k 2 | md5 > last-js-build.md5
|
|
|
|
find src -type f \( -name "*.scss" \) -exec md5 {} \; | sort -k 2 | md5 > last-sass-build.md5
|
|
|
|
find src -type f \( -name "composer.json" \) -exec md5 {} \; | sort -k 2 | md5 > last-composer-build.md5
|
2018-02-28 15:52:33 +00:00
|
|
|
find src -type f \( -name "package.json" -or -name "package-lock.json" \) -exec md5 {} \; | sort -k 2 | md5 > last-package-build.md5
|
2018-01-22 11:48:51 +00:00
|
|
|
else
|
2018-01-29 17:24:51 +00:00
|
|
|
find src -type f \( -name "*.js" -or -name "*.vue" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-js-build.md5
|
|
|
|
find src -type f \( -name "*.scss" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-sass-build.md5
|
|
|
|
find src -type f \( -name "composer.json" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-composer-build.md5
|
2018-02-28 15:54:46 +00:00
|
|
|
find src -type f \( -name "package.json" -or -name "package-lock.json" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-package-build.md5
|
2018-01-22 11:48:51 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-29 17:33:52 +00:00
|
|
|
new_md5_package=$(<last-package-build.md5)
|
|
|
|
if [ "$current_md5_package" != "$new_md5_package" ]
|
2017-12-04 18:34:47 +00:00
|
|
|
then
|
2018-01-29 18:29:28 +00:00
|
|
|
## Install js dependencies
|
2018-01-29 17:33:52 +00:00
|
|
|
npm install
|
|
|
|
fi
|
|
|
|
|
|
|
|
new_md5_composer=$(<last-composer-build.md5)
|
|
|
|
if [ "$current_md5_composer" != "$new_md5_composer" ]
|
|
|
|
then
|
|
|
|
## Install composer dependencies
|
|
|
|
composer install
|
2018-01-29 17:24:51 +00:00
|
|
|
fi
|
2018-01-29 16:42:59 +00:00
|
|
|
|
2018-01-29 17:24:51 +00:00
|
|
|
new_md5_sass=$(<last-sass-build.md5)
|
|
|
|
if [ "$current_md5_sass" != "$new_md5_sass" ]
|
|
|
|
then
|
2018-01-29 16:42:59 +00:00
|
|
|
## Compile SASS
|
|
|
|
sh compile-sass.sh
|
2017-12-04 18:34:47 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-29 17:33:52 +00:00
|
|
|
new_md5_js=$(<last-js-build.md5)
|
|
|
|
if [ "$current_md5_js" != "$new_md5_js" ]
|
2018-01-29 17:24:51 +00:00
|
|
|
then
|
2018-01-29 17:33:52 +00:00
|
|
|
npm run build
|
2018-01-29 17:24:51 +00:00
|
|
|
fi
|
2018-01-29 17:33:52 +00:00
|
|
|
### END npm build ###
|
2018-01-29 17:24:51 +00:00
|
|
|
|
2017-10-20 14:30:04 +00:00
|
|
|
|
2018-03-05 19:47:45 +00:00
|
|
|
echo "Updating files in $wp_plugin_dir"
|
|
|
|
rm -rf $wp_plugin_dir
|
|
|
|
mkdir $wp_plugin_dir
|
|
|
|
cp -R src/* $wp_plugin_dir/
|
|
|
|
rm -rf $wp_plugin_dir/scss
|
2018-03-01 20:41:28 +00:00
|
|
|
|
|
|
|
echo "Build complete!"
|