added build.sh
This commit is contained in:
parent
5b01ddc2a8
commit
5aea138f6a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/node_modules
|
||||
/dist
|
||||
|
48
build.sh
Normal file
48
build.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#/!bin/bash
|
||||
## PREBUILD PROCESS
|
||||
# check dist dir to be present and empty
|
||||
if [ ! -d "dist" ]; then
|
||||
## MAKE DIR
|
||||
mkdir "dist"
|
||||
echo "Directory dist created."
|
||||
else
|
||||
## CLEANUP
|
||||
rm -fr dist/*
|
||||
fi
|
||||
# Install dependencies
|
||||
#npm install
|
||||
|
||||
## PROJECT NEEDS
|
||||
echo "Building app... from $(git rev-parse --abbrev-ref HEAD)"
|
||||
#npm run-script build
|
||||
cp -r {.env,app.js,package.json,server,public} dist/
|
||||
|
||||
#Add version control for pm2
|
||||
cd dist
|
||||
#Add version control for pm2
|
||||
version=$(git describe)
|
||||
file_pkg="package.json"
|
||||
key=" \"version\": \""
|
||||
|
||||
count=$(echo ${version%%-*} | grep -o "\." | wc -l)
|
||||
if (( $count > 1 )); then
|
||||
version=${version%%-*}
|
||||
else
|
||||
version="${version%%-*}.0"
|
||||
fi
|
||||
if [ -f "$file_pkg" ] && [ ! -z "$version" ]; then
|
||||
version=" \"version\": \"$version\","
|
||||
sed -i "s|^.*$key.*|${version//\//\\/}|g" $file_pkg
|
||||
text=$(cat $file_pkg | grep -c "$version")
|
||||
if [ $text -eq 0 ]; then
|
||||
echo "Version couldn't be set"
|
||||
else
|
||||
echo "Version $version successfully applied to App"
|
||||
fi
|
||||
fi
|
||||
|
||||
## POST BUILD
|
||||
|
||||
cd -
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user