From d0dc2ae9719214354acf593186feb3b78e612833 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 17 Sep 2024 15:00:22 -0400 Subject: [PATCH] test-server.sh: move under tools --- .gitignore | 2 +- ikiwiki.setup | 2 +- test-server.sh => tools/test-server.sh | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) rename test-server.sh => tools/test-server.sh (68%) diff --git a/.gitignore b/.gitignore index 72d03f4..dd950df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ content/.ikiwiki public/ -http-server/ +tools/http-server/ diff --git a/ikiwiki.setup b/ikiwiki.setup index 161ca20..e717d51 100644 --- a/ikiwiki.setup +++ b/ikiwiki.setup @@ -101,7 +101,7 @@ timezone: :/etc/localtime # regexp of normally excluded files to include #include: ^\.htaccess$ # regexp of files that should be skipped -#exclude: ^(*\.private|Makefile)$ +exclude: ^(tools/.*|)$ # specifies the characters that are allowed in source filenames wiki_file_chars: -[:alnum:]+/.:_ # allow symlinks in the path leading to the srcdir (potentially insecure) diff --git a/test-server.sh b/tools/test-server.sh similarity index 68% rename from test-server.sh rename to tools/test-server.sh index 4364aad..cdbe7b1 100755 --- a/test-server.sh +++ b/tools/test-server.sh @@ -1,5 +1,7 @@ #!/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" @@ -8,7 +10,7 @@ for i in node npm git; do done # http-server not pulled, pulling -if [ ! -d "./http-server" ]; then +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 @@ -20,17 +22,19 @@ if [ ! -d "./http-server" ]; then fi # http-server depends not pulled, pulling -if [ ! -d "http-server/node_modules/" ]; then +if [ ! -d "$SCRIPT_DIR/http-server/node_modules/" ]; then echo ">> http-server dependencies not pulled, pulling" - npm --prefix ./http-server i + npm --prefix "$SCRIPT_DIR"/http-server i fi # website not built, building -if [ ! -d "./public" ]; then +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 ./http-server/bin/http-server -c-1 ./public +node "$SCRIPT_DIR"/http-server/bin/http-server -c-1 "$SCRIPT_DIR"/../public