Skip to content

Commit 018dcd7

Browse files
committed
Move initialization tasks to a function
1 parent 0f8cc0e commit 018dcd7

File tree

1 file changed

+22
-6
lines changed
  • tools/snippets/bin

1 file changed

+22
-6
lines changed

tools/snippets/bin/cli

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@ var main = require( './../lib' );
1414

1515
// FUNCTIONS //
1616

17+
/**
18+
* Performs initialization tasks.
19+
*
20+
* @private
21+
* @example
22+
* init();
23+
*/
24+
function init() {
25+
var opts;
26+
27+
// Check if newer versions exist for this package:
28+
opts = {
29+
'pkg': pkg
30+
};
31+
notifier( opts ).notify();
32+
33+
// Set the process title to allow the process to be more easily identified:
34+
process.title = pkg.name;
35+
process.stdout.on( 'error', process.exit );
36+
} // end FUNCTION init()
37+
1738
/**
1839
* Prints usage information.
1940
*
@@ -55,12 +76,7 @@ var args;
5576

5677
// MAIN //
5778

58-
// Check if newer versions exist for this package:
59-
notifier( { 'pkg': pkg } ).notify();
60-
61-
// Set the process title to allow the process to be more easily identified:
62-
process.title = pkg.name;
63-
process.stdout.on( 'error', process.exit );
79+
init();
6480

6581
// Parse command-line arguments:
6682
args = parseArgs( process.argv.slice( 2 ), opts );

0 commit comments

Comments
 (0)