Permalink
Browse files

minor tweaks to our custom binary

  • Loading branch information...
1 parent f2f99f8 commit 43eb6fb57e1dd8cecc1af3d850c3f2e27cb9b862 @mklabs committed Apr 11, 2012
Showing with 18 additions and 22 deletions.
  1. +17 −6 bin/h5bp
  2. +1 −16 bin/help.txt
View
@@ -1,12 +1,21 @@
#!/usr/bin/env node
var fs = require('fs'),
join = require('path').join,
- help = join(__dirname, 'help.txt'),
- cli = require('grunt/lib/grunt/cli');
+ help = join(__dirname, 'help.txt');
-// register this plugin to grunt npm tasks
-var grunt = require('grunt').npmTasks(join(__dirname, '../')),
- opts = cli.options,
+// grunt with the plugin registered
+var grunt = require('grunt').npmTasks(join(__dirname, '../'));
+
+// Get back a reference to the internal grunt cli object (Yes, it's hacky) We
+// need this to be able to read grunt command line parsed options and tasks to
+// run to hook our internal additional logic.
+//
+// Another (nicer) alternative is to redo the command line parsing with nopt,
+// but it'll add yet another dependency for a very little thing
+var cli = require('grunt/lib/grunt/cli');
+
+// command line options and remaining args
+var opts = cli.options,
cmds = cli.tasks,
route = cmds.join(' ').trim('');
@@ -16,13 +25,15 @@ if(/^help/.test(route)) {
cli.tasks = cmds.join(':');
}
+// add the plugin version on `--version`
if(opts.version) {
console.log('h5bp v%s', require('../package.json').version);
}
+// `h5bp init` -> `grunt init:h5bp`
if(/^init$/.test(route)) {
cli.tasks = 'init:h5bp';
}
// the grunt cli
-cli(opts);
+grunt.cli();
View
@@ -9,24 +9,9 @@ Usage:
A built-in help "task" may be used to get further information on a given topic:
h5bp help configuration
- h5bp help dom
- h5bp help home
- h5bp help install
h5bp help overview
- h5bp help plugins link-plugin
- h5bp help plugins rev-plugin
- h5bp help plugins script-plugin
- h5bp help tasks clean
- h5bp help tasks concat
- h5bp help tasks connect
h5bp help tasks css
- h5bp help tasks min
- h5bp help tasks mkdirs
- h5bp help tasks rev
- h5bp help tasks serve
- h5bp help tasks tasks
- h5bp help tasks usemin
- h5bp help test
+ ...
Available tasks the h5bp plugin provides (for a full list, type h5bp --help)

0 comments on commit 43eb6fb

Please sign in to comment.