#!/usr/bin/env bash if [[ $DEBUG != "" ]]; then set -x fi set -o errexit set -o pipefail if ! [ -x node_modules/.bin/marked-man ]; then ps=0 if [ -f .building_marked-man ]; then pid=$(cat .building_marked-man) ps=$(ps -p $pid | grep $pid | wc -l) || true fi if [ -f .building_marked-man ] && [ $ps != 0 ]; then while [ -f .building_marked-man ]; do sleep 1 done else # a race to see which make process will be the one to install marked-man echo $$ > .building_marked-man sleep 1 if [ $(cat .building_marked-man) == $$ ]; then make node_modules/.bin/marked-man rm .building_marked-man else while [ -f .building_marked-man ]; do sleep 1 done fi fi fi if ! [ -x node_modules/.bin/marked ]; then ps=0 if [ -f .building_marked ]; then pid=$(cat .building_marked) ps=$(ps -p $pid | grep $pid | wc -l) || true fi if [ -f .building_marked ] && [ $ps != 0 ]; then while [ -f .building_marked ]; do sleep 1 done else # a race to see which make process will be the one to install marked echo $$ > .building_marked sleep 1 if [ $(cat .building_marked) == $$ ]; then make node_modules/.bin/marked rm .building_marked else while [ -f .building_marked ]; do sleep 1 done fi fi fi src=$1 dest=$2 name=$(basename ${src%.*}) date=$(date -u +'%Y-%m-%d %H:%M:%S') version=$(node bin/npm-cli.js -v) mkdir -p $(dirname $dest) html_replace_tokens () { local url=$1 sed "s|@NAME@|$name|g" \ | sed "s|@DATE@|$date|g" \ | sed "s|@URL@|$url|g" \ | sed "s|@VERSION@|$version|g" \ | perl -p -e 's/
\3<\/p>/g' \
| perl -p -e 's/npm-npm/npm/g' \
| perl -p -e 's/([^"-])(npm-)?README(?!\.html)(\(1\))?/\1README<\/a>/g' \
| perl -p -e 's/