Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Change the way npm help works, so that it will work with man programs…
Browse files Browse the repository at this point in the history
… that stubbornly refuse to take a troff file as an argument

That is, make it work on Solaris.
  • Loading branch information
isaacs committed Sep 21, 2010
1 parent f9071cf commit dbee5c3
Show file tree
Hide file tree
Showing 38 changed files with 19 additions and 11 deletions.
19 changes: 11 additions & 8 deletions Makefile
@@ -1,10 +1,10 @@


docs = $(shell find doc -name '*.md' \ docs = $(shell find doc -name '*.md' \
|sed 's|.md|.1|g' \ |sed 's|.md|.1|g' \
|sed 's|doc/|man/|g' \ |sed 's|doc/|man1/|g' \
) )
doc_subfolders = $(shell find doc -type d \ doc_subfolders = $(shell find doc -type d \
|sed 's|doc/|man/|g' \ |sed 's|doc/|man1/|g' \
) )


install: install:
Expand All @@ -23,20 +23,23 @@ uninstall:
node cli.js cache clean node cli.js cache clean
node cli.js rm npm node cli.js rm npm


man: $(doc_subfolders) man: man1
@if ! test -d man ; then mkdir -p man ; fi @true

man1: $(doc_subfolders)
@if ! test -d man1 ; then mkdir -p man1 ; fi


doc: man $(docs) doc: man1 $(docs)
@true @true


# use `npm install ronn` for this to work. # use `npm install ronn` for this to work.
man/%.1: doc/%.md man1/%.1: doc/%.md
ronn --roff $< > $@ ronn --roff $< > $@


man/%/: doc/%/ man1/%/: doc/%/
@if ! test -d $@ ; then mkdir -p $@ ; fi @if ! test -d $@ ; then mkdir -p $@ ; fi


test: test:
./test/run.sh ./test/run.sh


.PHONY: install install-dev link doc clean uninstall test .PHONY: install install-dev link doc clean uninstall test man
9 changes: 7 additions & 2 deletions lib/help.js
Expand Up @@ -7,8 +7,13 @@ module.exports = help


function help (args, cb) { function help (args, cb) {
var section = args.shift() || "help" var section = args.shift() || "help"
fs.stat(path.join(__dirname, "../man/"+section+".1"), function (e, o) { fs.stat(path.join(__dirname, "../man1/"+section+".1"), function (e, o) {
if (e) return cb(new Error("Help section not found: "+section)) if (e) return cb(new Error("Help section not found: "+section))
exec("man", [path.join(__dirname, "../man/"+section+".1")], cb) // function exec (cmd, args, env, takeOver, cb) {
var manpath = path.join(__dirname, "..")
, env = {}
Object.keys(process.env).forEach(function (i) { env[i] = process.env[i] })
env.MANPATH = manpath
exec("man", [section], env, true, cb)
}) })
} }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -27,7 +27,7 @@
{ "mail" : "npm-@googlegroups.com" { "mail" : "npm-@googlegroups.com"
, "web" : "http://github.com/isaacs/npm/issues" , "web" : "http://github.com/isaacs/npm/issues"
} }
, "directories" : { "doc" : "./doc", "man" : "./man", "lib" : "./lib" } , "directories" : { "doc" : "./doc", "man" : "./man1", "lib" : "./lib" }
, "bin" : { "npm" : "./cli.js" } , "bin" : { "npm" : "./cli.js" }
, "main" : "npm" , "main" : "npm"
, "engines" : { "node" : ">=0.2.0" } , "engines" : { "node" : ">=0.2.0" }
Expand Down

0 comments on commit dbee5c3

Please sign in to comment.