Skip to content

Commit ce6bfe0

Browse files
committed
in dev task, run hugo server if hugo is installed
1 parent b3514b0 commit ce6bfe0

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

scripts/deploy-docs.sh

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
#!/bin/bash
22

33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4-
HUGO_BIN=${HUGO_BIN:="hugo"}
54

6-
# check for hugo
5+
source hugo-check.sh
76

8-
if ! [ -x "$(command -v $HUGO_BIN)" ]; then
9-
echo "Error: could not find Hugo (looked for '$HUGO_BIN')" >&2
10-
echo
11-
echo "If Hugo is installed but the command is not named 'hugo', set HUGO_BIN to the correct command name:" >&2
12-
echo
13-
echo " export HUGO_BIN=\"my-hugo\"" >&2
14-
echo
15-
echo "If Hugo is not installed, see https://gohugo.io/getting-started/quick-start/" >&2
16-
exit 1
17-
fi
7+
hugoNoisyCheck || exit 1
188

199
# clean and run build
2010

2111
pushd $DIR > /dev/null
2212
pushd ../docs/ > /dev/null
2313

14+
echo "Cleaning public/ dir."
15+
rm -rf public
16+
2417
echo "Building hugo docs."
2518
hugo
2619

2720
echo "Building storybook."
28-
mkdir public/demo
2921
npm run build-storybook
22+
mkdir public/demo
3023
cp -r ../.storybook_out/* public/demo
3124

3225
echo "Pushing to github pages."

scripts/dev.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@ for el in "$@"; do
66
CMD="$CMD --scope \"*/$el\""
77
done
88

9+
source scripts/hugo-check.sh
10+
if hugoCheck; then
11+
pushd docs > /dev/null
12+
hugo server &
13+
popd > /dev/null
14+
else
15+
echo "Not running Hugo server (docs site) becuase hugo is not installed."
16+
fi
17+
918
eval $CMD

scripts/hugo-check.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
HUGO_BIN=${HUGO_BIN:="hugo"}
4+
5+
hugoCheck() {
6+
command -v $HUGO_BIN
7+
return $?
8+
}
9+
10+
hugoNoisyCheck() {
11+
hugoCheck && return 0
12+
13+
echo "Error: could not find Hugo (looked for '$HUGO_BIN')" >&2
14+
echo
15+
echo "If Hugo is installed but the command is not named 'hugo', set HUGO_BIN to the correct command name:" >&2
16+
echo
17+
echo " export HUGO_BIN=\"my-hugo\"" >&2
18+
echo
19+
echo "If Hugo is not installed, see https://gohugo.io/getting-started/quick-start/" >&2
20+
return 1
21+
}

0 commit comments

Comments
 (0)