-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitproject.sh
executable file
·51 lines (40 loc) · 1007 Bytes
/
initproject.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
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Invalid argument(s)"
exit 1
fi
if [ ! -d "$2" ]; then
echo "$2 does not exist"
exit 1
fi
TEMPLATE_NAME=sublime-project
TEMPLATE=https://github.com/Straeng/sublime-project.git
PROJECT_NAME=$1
DIR=$2
pushd $DIR
# the temp directory used, within $DIR
WORK_DIR=`mktemp -d -p "$DIR"`
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
echo "Deleted temp working directory $WORK_DIR"
}
trap cleanup EXIT
git clone $TEMPLATE $WORK_DIR
pushd $WORK_DIR
rm -rf .git
rm README.md
rm initproject.sh
mv template.sublime-project ${PROJECT_NAME}.sublime-project
sed -i "s/${TEMPLATE_NAME}/${PROJECT_NAME}/g" CMakeLists.txt
popd
mkdir -p $DIR/$PROJECT_NAME
cp -r $WORK_DIR/. $DIR/$PROJECT_NAME
mkdir -p $DIR/$PROJECT_NAME/build
popd
subl --project $DIR/$PROJECT_NAME/${PROJECT_NAME}.sublime-project