From 13abcd59587fa6ba60af33d71896d2cc149f5485 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 4 Sep 2020 19:49:18 +0800 Subject: [PATCH] Improve the init tool & fix the deploy tool. --- tools/deploy.sh | 2 +- tools/init.sh | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/deploy.sh b/tools/deploy.sh index beeaaa7..4de390d 100755 --- a/tools/deploy.sh +++ b/tools/deploy.sh @@ -24,7 +24,7 @@ init() { } backup() { - mv _site "$_backup_dir" + mv _site/* "$_backup_dir" mv .git "$_backup_dir" # When adding custom domain from Github website, diff --git a/tools/init.sh b/tools/init.sh index 2c0c71c..51393dd 100755 --- a/tools/init.sh +++ b/tools/init.sh @@ -24,13 +24,18 @@ help() { check_init() { local _has_inited=false - if [[ -d .github ]]; then - if [[ -f .github/workflows/$ACTIONS_WORKFLOW && \ - $(find .github/workflows/ -type f -name "*.yml" | wc -l) == 1 ]]; then - _has_inited=true + if [[ ! -d docs ]]; then + if [[ ! -d .github ]]; then + _has_inited=true # --no-gh + else + if [[ -f .github/workflows/$ACTIONS_WORKFLOW ]]; then + # on BSD, the `wc` could contains blank + local _count="$(find .github/workflows/ -type f -name "*.yml" | wc -l)" + if [[ ${_count//[[:blank:]]/} == 1 ]]; then + _has_inited=true + fi + fi fi - else - _has_inited=true fi if $_has_inited; then