forked from ocaml-sf/learn-ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(update-index.sh): Add a script to update docs/index.md
Related: ocaml-sf#490 Co-authored-by: Erik Martin-Dorel <erik@martin-dorel.org>
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script updates 'docs/index.md' from 'README.md', | ||
# and changes github.com/…/learn-ocaml/…/docs URLs to relative paths, | ||
# so that github.io pages work independently of github.com src files. | ||
|
||
srcdir=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd) | ||
|
||
readme=$(readlink -f "$srcdir/../README.md") | ||
index=$(readlink -f "$srcdir/../docs/index.md") | ||
|
||
if [[ ! -r "$readme" ]] | ||
then | ||
echo "Error: '$readme': file does not exist or is unreadable" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -w "$index" ]] | ||
then | ||
echo "Error: '$index': file does not exist or is not writable" | ||
exit 1 | ||
fi | ||
|
||
url="https://github.com/ocaml-sf/learn-ocaml/blob/master/docs" | ||
|
||
sed -e "s;$url;.;g" "$readme" > "$index" |