-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstage
executable file
·51 lines (42 loc) · 1.45 KB
/
stage
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
## Quick script to automate building and staging a docstools site
## for use with a makefile that supports html building and staging.
## Script takes no arguments.
## Script performs the following:
## 1. Clean build dir
## 2. make html
## 3. make stage
## 4. Opens the resulting stage build in browser
############################################################
## BEGIN SCRIPT ##
##################
TMPFILE=/tmp/stage$$.tmp
# Must be in a git repo:
GITROOT=`git rev-parse --show-toplevel 2>&1`
if [ `echo $GITROOT | grep -c '^fatal: not a git repository'` -gt 0 ]; then
echo -e "\nERROR: Not in a git repo!"
echo -e " Aborting...\n"
exit;
fi
# Clean:
rm -rf $GITROOT/build/*
# Run make / make stage (and squash make html logspam):
cd $GITROOT
make html 2>&1 >/dev/null | egrep -v " Xferd | Dload | --:--:-- "
echo -e "\n ##################"
echo " # Build complete #"
echo -e " ##################\n"
echo " staging ... "
# Redirect stage to grab URL from (also squash stage logspam):
make stage | tee $TMPFILE 2>&1 > /dev/null
STAGE_URL=`tail -1 $TMPFILE | cut -d ' ' -f 3`
rm -f $TMPFILE
echo -e "\n ##################"
echo " # Stage complete #"
echo -e " ##################\n"
echo " $STAGE_URL"
echo ""
# OSX ONLY: Open staged build in browser:
open $STAGE_URL
# LINUX ONLY: Open staged build in browser (tries everything):
#xdg-open $STAGE_URL || sensible-browser $STAGE_URL || x-www-browser $STAGE_URL || gnome-open $STAGE_URL