Skip to content
This repository
tree: 205a05683f
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 49 lines (43 sloc) 1.319 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/bin/bash

if [[ $DEBUG != "" ]]; then
set -x
fi
set -o errexit
set -o pipefail

[ -x ./node_modules/.bin/ronn ] || node cli.js install ronn

src=$1
dest=$2
name=$(basename ${src%.*})
date=$(date -u +'%Y-%M-%d %H:%m:%S')
version=$(node cli.js -v)

mkdir -p $(dirname $dest)

case $dest in
  *.html)
    (cat html/dochead.html && \
     ./node_modules/.bin/ronn -f $src && \
     cat html/docfoot.html )\
    | sed "s|@NAME@|$name|g" \
    | sed "s|@DATE@|$date|g" \
    | sed "s|@VERSION@|$version|g" \
    | perl -pi -e 's/<h1>npm(-?[^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>npm\1<\/h1> <p>\2<\/p>/g' \
    | perl -pi -e 's/npm-npm/npm/g' \
    | perl -pi -e 's/([^"-])(npm-)?README(\(1\))?/\1<a href="README.html">README<\/a>/g' \
    | perl -pi -e 's/<title><a href="README.html">README<\/a><\/title>/<title>README<\/title>/g' \
    | perl -pi -e 's/([^"-])npm-([^\(]+)\(1\)/\1<a href="\2.html">\2<\/a>/g' \
    | perl -pi -e 's/([^"-])npm\(1\)/\1<a href="npm.html">npm<\/a>/g' \
    > $dest
    exit $?
    ;;
  *.1)
    ./node_modules/.bin/ronn --roff $src \
    | sed "s|@VERSION@|$version|g" \
    | perl -pi -e 's/npm\\-([^\(]*)\([0-9]\)/npm help \1/g' \
    | perl -pi -e 's/npm\([0-9]\)/npm help npm/g' \
    > $dest
    exit $?
    ;;
  *)
    echo "Invalid destination type: $dest" >&2
    exit 1
    ;;
esac
Something went wrong with that request. Please try again.