From dbee5c3b14f10fac8b15e661a8e5ed72d4e147c0 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 21 Sep 2010 16:25:47 -0700 Subject: [PATCH] Change the way npm help works, so that it will work with man programs that stubbornly refuse to take a troff file as an argument That is, make it work on Solaris. --- Makefile | 19 +++++++++++-------- lib/help.js | 9 +++++++-- {man => man1}/activate.1 | 0 {man => man1}/adduser.1 | 0 {man => man1}/build.1 | 0 {man => man1}/bundle.1 | 0 {man => man1}/cache.1 | 0 {man => man1}/coding-style.1 | 0 {man => man1}/config.1 | 0 {man => man1}/deactivate.1 | 0 {man => man1}/developers.1 | 0 {man => man1}/folders.1 | 0 {man => man1}/future-ideas/deploy.1 | 0 {man => man1}/future-ideas/remote.1 | 0 {man => man1}/future-ideas/site.1 | 0 {man => man1}/help.1 | 0 {man => man1}/install.1 | 0 {man => man1}/json.1 | 0 {man => man1}/link.1 | 0 {man => man1}/list.1 | 0 {man => man1}/ln.1 | 0 {man => man1}/ls.1 | 0 {man => man1}/npm.1 | 0 {man => man1}/owner.1 | 0 {man => man1}/publish.1 | 0 {man => man1}/rebuild.1 | 0 {man => man1}/restart.1 | 0 {man => man1}/rm.1 | 0 {man => man1}/scripts.1 | 0 {man => man1}/start.1 | 0 {man => man1}/stop.1 | 0 {man => man1}/tag.1 | 0 {man => man1}/test.1 | 0 {man => man1}/uninstall.1 | 0 {man => man1}/unpublish.1 | 0 {man => man1}/update.1 | 0 {man => man1}/view.1 | 0 package.json | 2 +- 38 files changed, 19 insertions(+), 11 deletions(-) rename {man => man1}/activate.1 (100%) rename {man => man1}/adduser.1 (100%) rename {man => man1}/build.1 (100%) rename {man => man1}/bundle.1 (100%) rename {man => man1}/cache.1 (100%) rename {man => man1}/coding-style.1 (100%) rename {man => man1}/config.1 (100%) rename {man => man1}/deactivate.1 (100%) rename {man => man1}/developers.1 (100%) rename {man => man1}/folders.1 (100%) rename {man => man1}/future-ideas/deploy.1 (100%) rename {man => man1}/future-ideas/remote.1 (100%) rename {man => man1}/future-ideas/site.1 (100%) rename {man => man1}/help.1 (100%) rename {man => man1}/install.1 (100%) rename {man => man1}/json.1 (100%) rename {man => man1}/link.1 (100%) rename {man => man1}/list.1 (100%) rename {man => man1}/ln.1 (100%) rename {man => man1}/ls.1 (100%) rename {man => man1}/npm.1 (100%) rename {man => man1}/owner.1 (100%) rename {man => man1}/publish.1 (100%) rename {man => man1}/rebuild.1 (100%) rename {man => man1}/restart.1 (100%) rename {man => man1}/rm.1 (100%) rename {man => man1}/scripts.1 (100%) rename {man => man1}/start.1 (100%) rename {man => man1}/stop.1 (100%) rename {man => man1}/tag.1 (100%) rename {man => man1}/test.1 (100%) rename {man => man1}/uninstall.1 (100%) rename {man => man1}/unpublish.1 (100%) rename {man => man1}/update.1 (100%) rename {man => man1}/view.1 (100%) diff --git a/Makefile b/Makefile index 54e7dffb2b6..a4b2d9afdff 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ docs = $(shell find doc -name '*.md' \ |sed 's|.md|.1|g' \ - |sed 's|doc/|man/|g' \ + |sed 's|doc/|man1/|g' \ ) doc_subfolders = $(shell find doc -type d \ - |sed 's|doc/|man/|g' \ + |sed 's|doc/|man1/|g' \ ) install: @@ -23,20 +23,23 @@ uninstall: node cli.js cache clean node cli.js rm npm -man: $(doc_subfolders) - @if ! test -d man ; then mkdir -p man ; fi +man: man1 + @true + +man1: $(doc_subfolders) + @if ! test -d man1 ; then mkdir -p man1 ; fi -doc: man $(docs) +doc: man1 $(docs) @true # use `npm install ronn` for this to work. -man/%.1: doc/%.md +man1/%.1: doc/%.md ronn --roff $< > $@ -man/%/: doc/%/ +man1/%/: doc/%/ @if ! test -d $@ ; then mkdir -p $@ ; fi test: ./test/run.sh -.PHONY: install install-dev link doc clean uninstall test +.PHONY: install install-dev link doc clean uninstall test man diff --git a/lib/help.js b/lib/help.js index 8323632b9b8..1e1647c2d65 100644 --- a/lib/help.js +++ b/lib/help.js @@ -7,8 +7,13 @@ module.exports = help function help (args, cb) { 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)) - 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) }) } diff --git a/man/activate.1 b/man1/activate.1 similarity index 100% rename from man/activate.1 rename to man1/activate.1 diff --git a/man/adduser.1 b/man1/adduser.1 similarity index 100% rename from man/adduser.1 rename to man1/adduser.1 diff --git a/man/build.1 b/man1/build.1 similarity index 100% rename from man/build.1 rename to man1/build.1 diff --git a/man/bundle.1 b/man1/bundle.1 similarity index 100% rename from man/bundle.1 rename to man1/bundle.1 diff --git a/man/cache.1 b/man1/cache.1 similarity index 100% rename from man/cache.1 rename to man1/cache.1 diff --git a/man/coding-style.1 b/man1/coding-style.1 similarity index 100% rename from man/coding-style.1 rename to man1/coding-style.1 diff --git a/man/config.1 b/man1/config.1 similarity index 100% rename from man/config.1 rename to man1/config.1 diff --git a/man/deactivate.1 b/man1/deactivate.1 similarity index 100% rename from man/deactivate.1 rename to man1/deactivate.1 diff --git a/man/developers.1 b/man1/developers.1 similarity index 100% rename from man/developers.1 rename to man1/developers.1 diff --git a/man/folders.1 b/man1/folders.1 similarity index 100% rename from man/folders.1 rename to man1/folders.1 diff --git a/man/future-ideas/deploy.1 b/man1/future-ideas/deploy.1 similarity index 100% rename from man/future-ideas/deploy.1 rename to man1/future-ideas/deploy.1 diff --git a/man/future-ideas/remote.1 b/man1/future-ideas/remote.1 similarity index 100% rename from man/future-ideas/remote.1 rename to man1/future-ideas/remote.1 diff --git a/man/future-ideas/site.1 b/man1/future-ideas/site.1 similarity index 100% rename from man/future-ideas/site.1 rename to man1/future-ideas/site.1 diff --git a/man/help.1 b/man1/help.1 similarity index 100% rename from man/help.1 rename to man1/help.1 diff --git a/man/install.1 b/man1/install.1 similarity index 100% rename from man/install.1 rename to man1/install.1 diff --git a/man/json.1 b/man1/json.1 similarity index 100% rename from man/json.1 rename to man1/json.1 diff --git a/man/link.1 b/man1/link.1 similarity index 100% rename from man/link.1 rename to man1/link.1 diff --git a/man/list.1 b/man1/list.1 similarity index 100% rename from man/list.1 rename to man1/list.1 diff --git a/man/ln.1 b/man1/ln.1 similarity index 100% rename from man/ln.1 rename to man1/ln.1 diff --git a/man/ls.1 b/man1/ls.1 similarity index 100% rename from man/ls.1 rename to man1/ls.1 diff --git a/man/npm.1 b/man1/npm.1 similarity index 100% rename from man/npm.1 rename to man1/npm.1 diff --git a/man/owner.1 b/man1/owner.1 similarity index 100% rename from man/owner.1 rename to man1/owner.1 diff --git a/man/publish.1 b/man1/publish.1 similarity index 100% rename from man/publish.1 rename to man1/publish.1 diff --git a/man/rebuild.1 b/man1/rebuild.1 similarity index 100% rename from man/rebuild.1 rename to man1/rebuild.1 diff --git a/man/restart.1 b/man1/restart.1 similarity index 100% rename from man/restart.1 rename to man1/restart.1 diff --git a/man/rm.1 b/man1/rm.1 similarity index 100% rename from man/rm.1 rename to man1/rm.1 diff --git a/man/scripts.1 b/man1/scripts.1 similarity index 100% rename from man/scripts.1 rename to man1/scripts.1 diff --git a/man/start.1 b/man1/start.1 similarity index 100% rename from man/start.1 rename to man1/start.1 diff --git a/man/stop.1 b/man1/stop.1 similarity index 100% rename from man/stop.1 rename to man1/stop.1 diff --git a/man/tag.1 b/man1/tag.1 similarity index 100% rename from man/tag.1 rename to man1/tag.1 diff --git a/man/test.1 b/man1/test.1 similarity index 100% rename from man/test.1 rename to man1/test.1 diff --git a/man/uninstall.1 b/man1/uninstall.1 similarity index 100% rename from man/uninstall.1 rename to man1/uninstall.1 diff --git a/man/unpublish.1 b/man1/unpublish.1 similarity index 100% rename from man/unpublish.1 rename to man1/unpublish.1 diff --git a/man/update.1 b/man1/update.1 similarity index 100% rename from man/update.1 rename to man1/update.1 diff --git a/man/view.1 b/man1/view.1 similarity index 100% rename from man/view.1 rename to man1/view.1 diff --git a/package.json b/package.json index 0bcb63de08c..78a5a5836c1 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ { "mail" : "npm-@googlegroups.com" , "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" } , "main" : "npm" , "engines" : { "node" : ">=0.2.0" }