Skip to content

Commit

Permalink
add support for GH_TOC_TOKEN env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Dec 29, 2018
1 parent 0d36e74 commit c2479a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ gh_toc_load() {
gh_toc_md2html() {
local gh_file_md=$1
URL=https://api.github.com/markdown/raw
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
if [ -z "$GH_TOC_TOKEN" ]; then
TOKEN=$GH_TOC_TOKEN
else
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
fi
if [ -f "$TOKEN" ]; then
URL="$URL?access_token=$(cat $TOKEN)"
fi
# echo $URL 1>&2
OUTPUT="$(curl -s --user-agent "$gh_user_agent" \
--data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
$URL)"
Expand Down

0 comments on commit c2479a7

Please sign in to comment.