forked from h5bp/ant-build-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createproject.sh
executable file
·76 lines (62 loc) · 1.74 KB
/
createproject.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
#!/usr/bin/env bash
#Generate a new project from your HTML5 Boilerplate repo clone
#by: Rick Waldron & Michael Cetrulo
##first run
# $ cd html5-boilerplate/build
# $ chmod +x createproject.sh && ./createproject.sh [new_project]
##usage
# $ cd html5-boilerplate/build
# $ ./createproject.sh [new_project]
#
# If [new_project] is not specified the user we will prompted to enter it.
#
# The format of [new_project] should ideally be lowercase letters with no
# spaces as it represents the directory name that your new project will live
# in.
#
# If the new project is specified as just a name ( "foo" ) then the path
# will be a sibling to html5-boilerplate's directory.
#
# If the new project is specified with an absolute path ( "/home/user/foo" )
# that path will be used.
#
# find project root (also ensure script is ran from within repo)
src=$(git rev-parse --show-toplevel) || {
echo "try running the script from within html5-boilerplate directories." >&2
exit 1
}
[[ -d $src ]] || {
echo "fatal: could not determine html5-boilerplate's root directory." >&2
echo "try updating git." >&2
exit 1
}
if [ $# -eq 1 ]
then
# get a name for new project from command line arguments
name="$1"
fi
# get a name for new project from input
while [[ -z $name ]]
do
echo "To create a new html5-boilerplate project, enter a new directory name:"
read name || exit
done
if [[ "$name" = /* ]]
then
dst=$name
else
dst=$src/../$name
fi
if [[ -d $dst ]]
then
echo "$dst exists"
else
#create new project
mkdir -p -- "$dst" || exit 1
#success message
echo "Created Directory: $dst"
cd -- "$src"
cp -vr -- css js img build *.html *.xml *.txt *.png *.ico .htaccess "$dst"
#success message
echo "Created Project: $dst"
fi