Open Raynos opened 10 years ago
just published a new version if it with more lookup paths including bin/usage.md. now you can also pass show-help a transform function (https://github.com/azer/show-help#options). I clonned your repo and tried this and worked;
diff --git a/bin/help.js b/bin/help.js
index 117ce9f..372f36a 100644
--- a/bin/help.js
+++ b/bin/help.js
@@ -1,21 +1,6 @@
-var path = require('path');
-var fs = require('fs');
var msee = require('msee');
-var template = require('string-template');
+var help = require('show-help')
-function printHelp(opts) {
- opts = opts || {};
-
- var loc = path.join(__dirname, 'usage.md');
- var content = fs.readFileSync(loc, 'utf8');
-
- content = template(content, {
- cmd: opts.cmd || 'npm-shrinkwrap'
- });
-
- return console.log(msee.parse(content, {
- paragraphStart: '\n'
- }));
+module.exports = function () {
+ help({ transform: msee.parse });
}
-
-module.exports = printHelp;
Can I add a { markdown: true }
option to show-help
to move the msee.parse()
and { paragraphStart '\n' }
into show-help
?
that was my first intend but then noticed that msee has some dependencies that are kinda big for putting in show-help
I see, it does include all of esprima.
I kind of need to wrap the msee specific stuff in some kind of module otherwise there is not enough benefit in including a show-help
module.
We could fix msee
to have an optional dependency on cardinal
.
we can also create a new module like show-help-markdown
that would work too tbh.
I have a convention like https://github.com/uber/npm-shrinkwrap/blob/master/bin/help.js and https://github.com/uber/npm-shrinkwrap/blob/master/bin/usage.md for showing help.
The features I use are
msee
for parsing files that end in.md
, readingbin/usage.md
and passing in an object toshowHelp()
where it will use thestring-template
module to fill in the object.