File tree Expand file tree Collapse file tree 1 file changed +38
-17
lines changed
Expand file tree Collapse file tree 1 file changed +38
-17
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,42 @@ var opts = require( './opts.json' );
1212var TODO = require ( './../lib' ) ;
1313
1414
15+ // FUNCTIONS //
16+
17+ /**
18+ * Prints usage information.
19+ *
20+ * @private
21+ * @example
22+ * help();
23+ * // => '...'
24+ */
25+ function help ( ) {
26+ var fpath = path . join ( __dirname , 'usage.txt' ) ;
27+ fs . createReadStream ( fpath )
28+ . pipe ( process . stdout )
29+ . on ( 'close' , onClose ) ;
30+
31+ function onClose ( ) {
32+ process . exit ( 0 ) ;
33+ }
34+ } // end FUNCTION help()
35+
36+ /**
37+ * Prints the package version.
38+ *
39+ * @private
40+ * @example
41+ * version();
42+ * // => '#.#.#'
43+ */
44+ function version ( ) {
45+ var msg = pkg . version . toString ( ) + '\n' ;
46+ process . stdout . write ( msg , 'utf8' ) ;
47+ process . exit ( 0 ) ;
48+ } // end FUNCTION version()
49+
50+
1551// VARIABLES //
1652
1753var args ;
@@ -32,26 +68,11 @@ notifier( { 'pkg': pkg } ).notify();
3268
3369args = parseArgs ( process . argv . slice ( 2 ) , opts ) ;
3470
35-
36- // HELP //
37-
38- function onClose ( ) {
39- process . exit ( 0 ) ;
40- }
41-
4271if ( args . help ) {
43- fs . createReadStream ( path . join ( __dirname , 'usage.txt' ) )
44- . pipe ( process . stdout )
45- . on ( 'close' , onClose ) ;
46- return ;
72+ return help ( ) ;
4773}
48-
49-
50- // VERSION //
51-
5274if ( args . version ) {
53- console . log ( pkg . version ) ;
54- return ;
75+ return version ( ) ;
5576}
5677
5778
You can’t perform that action at this time.
0 commit comments