summaryrefslogtreecommitdiff
path: root/deps/npm/scripts
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-11-04 15:08:12 -0800
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-11-05 10:35:43 -0800
commit28ae70ebad8debd8aa7b521a693aa3de89ad84d6 (patch)
treec5cd9142bbefe8f84c9555e07cafd677530cb7ef /deps/npm/scripts
parent272aa589af50566a20a491910d4dc40bb3692102 (diff)
downloadnode-new-28ae70ebad8debd8aa7b521a693aa3de89ad84d6.tar.gz
npm: Upgrade to v2.1.6
Diffstat (limited to 'deps/npm/scripts')
-rwxr-xr-xdeps/npm/scripts/doc-build.sh69
1 files changed, 42 insertions, 27 deletions
diff --git a/deps/npm/scripts/doc-build.sh b/deps/npm/scripts/doc-build.sh
index 3728259ac0..79629c63dc 100755
--- a/deps/npm/scripts/doc-build.sh
+++ b/deps/npm/scripts/doc-build.sh
@@ -66,44 +66,59 @@ version=$(node 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/<h1([^>]*)>([^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>\2<\/h1> <p>\3<\/p>/g' \
+ | perl -p -e 's/npm-npm/npm/g' \
+ | perl -p -e 's/([^"-])(npm-)?README(?!\.html)(\(1\))?/\1<a href="..\/..\/doc\/README.html">README<\/a>/g' \
+ | perl -p -e 's/<title><a href="[^"]+README.html">README<\/a><\/title>/<title>README<\/title>/g' \
+ | perl -p -e 's/([^"-])([^\(> ]+)(\(1\))/\1<a href="..\/cli\/\2.html">\2\3<\/a>/g' \
+ | perl -p -e 's/([^"-])([^\(> ]+)(\(3\))/\1<a href="..\/api\/\2.html">\2\3<\/a>/g' \
+ | perl -p -e 's/([^"-])([^\(> ]+)(\(5\))/\1<a href="..\/files\/\2.html">\2\3<\/a>/g' \
+ | perl -p -e 's/([^"-])([^\(> ]+)(\(7\))/\1<a href="..\/misc\/\2.html">\2\3<\/a>/g' \
+ | perl -p -e 's/\([1357]\)<\/a><\/h1>/<\/a><\/h1>/g' \
+ | (if [ $(basename $(dirname $dest)) == "doc" ]; then
+ perl -p -e 's/ href="\.\.\// href="/g'
+ else
+ cat
+ fi)
+}
+
+man_replace_tokens () {
+ sed "s|@VERSION@|$version|g" \
+ | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(1\)/npm help \2/g' \
+ | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(([57])\)/npm help \3 \2/g' \
+ | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(3\)/npm apihelp \2/g' \
+ | perl -p -e 's/npm\(1\)/npm help npm/g' \
+ | perl -p -e 's/npm\(3\)/npm apihelp npm/g'
+}
+
case $dest in
*.[1357])
./node_modules/.bin/marked-man --roff $src \
- | sed "s|@VERSION@|$version|g" \
- | perl -pi -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(1\)/npm help \2/g' \
- | perl -pi -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(([57])\)/npm help \3 \2/g' \
- | perl -pi -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(3\)/npm apihelp \2/g' \
- | perl -pi -e 's/npm\(1\)/npm help npm/g' \
- | perl -pi -e 's/npm\(3\)/npm apihelp npm/g' \
- > $dest
+ | man_replace_tokens > $dest
exit $?
;;
- *.html)
+
+ html/partial/*.html)
+ url=${dest/html\/partial\//}
+ cat $src | ./node_modules/.bin/marked | html_replace_tokens $url > $dest
+ ;;
+
+ html/*.html)
url=${dest/html\//}
(cat html/dochead.html && \
- cat $src | ./node_modules/.bin/marked &&
+ cat $src && \
cat html/docfoot.html)\
- | sed "s|@NAME@|$name|g" \
- | sed "s|@DATE@|$date|g" \
- | sed "s|@URL@|$url|g" \
- | sed "s|@VERSION@|$version|g" \
- | perl -pi -e 's/<h1([^>]*)>([^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>\2<\/h1> <p>\3<\/p>/g' \
- | perl -pi -e 's/npm-npm/npm/g' \
- | perl -pi -e 's/([^"-])(npm-)?README(?!\.html)(\(1\))?/\1<a href="..\/..\/doc\/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/([^"-])([^\(> ]+)(\(1\))/\1<a href="..\/cli\/\2.html">\2\3<\/a>/g' \
- | perl -pi -e 's/([^"-])([^\(> ]+)(\(3\))/\1<a href="..\/api\/\2.html">\2\3<\/a>/g' \
- | perl -pi -e 's/([^"-])([^\(> ]+)(\(5\))/\1<a href="..\/files\/\2.html">\2\3<\/a>/g' \
- | perl -pi -e 's/([^"-])([^\(> ]+)(\(7\))/\1<a href="..\/misc\/\2.html">\2\3<\/a>/g' \
- | perl -pi -e 's/\([1357]\)<\/a><\/h1>/<\/a><\/h1>/g' \
- | (if [ $(basename $(dirname $dest)) == "doc" ]; then
- perl -pi -e 's/ href="\.\.\// href="/g'
- else
- cat
- fi) \
+ | html_replace_tokens $url \
> $dest
exit $?
;;
+
*)
echo "Invalid destination type: $dest" >&2
exit 1