-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
94 lines (83 loc) · 2.19 KB
/
entrypoint.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# If any commands fail (exit code other than 0) entire script exits
set -e
# See if our project has a gulpfile either in the root directory if it's a theme
# or in the assets/ folder if it is a plugin
composer_path="./composer.json"
build_file_path="./gulpfile.js"
bower_file_path="./bower.json"
build_type=none
# Go to the working directory (current directory by default)
cd ${working_directory:-./}
# If we have composer dependencies make sure they are installed
if [ -f "$composer_path" ]
then
echo "Composer File found. Starting composer install."
composer install
fi
if [ -f "$build_file_path" ]
then
echo "Gulpfile found. Starting build process"
build_type=gulp
else
build_file_path="./gulpfile.babel.js"
if [ -f "$build_file_path" ]
then
echo "Gulpfile w/ Babel found. Starting build process"
build_type=gulp_yarn
fi
fi
if [ "$build_type" == "none" ]
then
echo "Gulpfile not found. Searching for Gruntfile instead."
build_file_path="./Gruntfile.js"
if [ -f "$build_file_path" ]
then
echo "Gruntfile found."
build_type=grunt
else
echo "No build file found. No build needed."
fi
fi
# check to see our build type and if so build using either gulp or grunt
if [ "$build_type" != "none" ]
then
if [ "$build_type" == "gulp_yarn" ]
then
echo "Yarn Install"
yarn global add gulp-cli
yarn install
# Only build if the build:production task exists in the build path
if grep -q build:production "$build_file_path";
then
echo "Building project using gulp"
gulp build:production
fi
else
echo "Initiating NPM Install"
npm install
# Only install and fire bower if we have a bower.json
if [ -f "$bower_file_path" ]
then
echo "Initiating Bower Install"
npm install -g bower
bower install --allow-root
fi
if [ $build_type = "gulp" ]
then
if grep -q build:production "$build_file_path";
then
echo "Building project using gulp"
npm install --global gulp-cli
gulp build:production
fi
else
# Make sure we have a build command within our grunt file
if grep -q build "$build_file_path";
then
echo "Building project using grunt"
grunt build
fi
fi
fi
fi