Skip to content

Commit 38a168f

Browse files
committed
Docusaurus config needs to be updated before building docs
1 parent 4cb0b80 commit 38a168f

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
script:
1212
- gulp build
1313
- gulp test --coverage
14+
- ./scripts/docs-config.sh
1415
- npm run docs
1516
- npm run typedoc
1617
- gulp package

scripts/deploy.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ set -e
55
TARGET_DIR='gh-pages'
66
TARGET_BRANCH='master'
77
TARGET_REPO_URL="https://$GITHUB_AUTH_TOKEN@github.com/chartjs/chartjs.github.io.git"
8-
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
98

9+
# Note: this code also exists in docs-config.sh
1010
# Make sure that this script is executed only for the release and master branches
11+
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
1112
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
1213
# Travis executes this script from the repository root, so at the same level than package.json
1314
VERSION=$(node -p -e "require('./package.json').version")
@@ -35,10 +36,9 @@ function update_with_tag {
3536
move_sample_scripts $tag
3637

3738
deploy_versioned_files $tag
38-
39-
sed -i -e "s/VERSION/$tag/g" "docs/$tag/docusaurus.config.js"
4039
}
4140

41+
# Note: this code also exists in docs-config.sh
4242
# tag is next|latest|master
4343
# https://www.chartjs.org/docs/$tag/
4444
# https://www.chartjs.org/samples/$tag/

scripts/docs-config.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Note: this code also exists in deploy.sh
6+
# Make sure that this script is executed only for the release and master branches
7+
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
8+
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
9+
# Travis executes this script from the repository root, so at the same level than package.json
10+
VERSION=$(node -p -e "require('./package.json').version")
11+
elif [ "$TRAVIS_BRANCH" == "master" ]; then
12+
VERSION="master"
13+
else
14+
echo "Skipping docs configuration because this is not the master or release branch"
15+
exit 0
16+
fi
17+
18+
# Note: this code also exists in deploy.sh
19+
# tag is next|latest|master
20+
# https://www.chartjs.org/docs/$tag/
21+
function update_config {
22+
local tag=''
23+
if [ "$VERSION" == "master" ]; then
24+
tag=master
25+
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
26+
tag=lastest
27+
else
28+
tag=next
29+
fi
30+
sed -i -e "s/VERSION/$tag/g" "docs/docusaurus.config.js"
31+
}
32+
33+
update_config

0 commit comments

Comments
 (0)