test-server.sh: move under tools
This commit is contained in:
parent
b468943328
commit
d0dc2ae971
3 changed files with 11 additions and 7 deletions
40
tools/test-server.sh
Executable file
40
tools/test-server.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
for i in node npm git; do
|
||||
if ! command -v $i &> /dev/null; then
|
||||
echo ">> $i could not be found, please install"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
# http-server not pulled, pulling
|
||||
if [ ! -d "$SCRIPT_DIR/http-server" ]; then
|
||||
echo ">> This script will pull a lightweight nodejs http-server from https://github.com/http-party/http-server and make ./public avaiable as local http service, are you okay with this?"
|
||||
read -p "Continue (y/n)?" choice
|
||||
case "$choice" in
|
||||
y|Y ) echo "yes";;
|
||||
n|N ) echo "no";;
|
||||
* ) echo "invalid";;
|
||||
esac
|
||||
git clone https://github.com/http-party/http-server
|
||||
fi
|
||||
|
||||
# http-server depends not pulled, pulling
|
||||
if [ ! -d "$SCRIPT_DIR/http-server/node_modules/" ]; then
|
||||
echo ">> http-server dependencies not pulled, pulling"
|
||||
npm --prefix "$SCRIPT_DIR"/http-server i
|
||||
fi
|
||||
|
||||
# website not built, building
|
||||
if [ ! -d "$SCRIPT_DIR/../public" ]; then
|
||||
echo ">> website not build, building"
|
||||
pushd "$SCRIPT_DIR"/..
|
||||
ikiwiki --setup ./ikiwiki.setup
|
||||
popd
|
||||
fi
|
||||
|
||||
# starting server
|
||||
echo ">> starting http server"
|
||||
node "$SCRIPT_DIR"/http-server/bin/http-server -c-1 "$SCRIPT_DIR"/../public
|
Loading…
Add table
Add a link
Reference in a new issue