1818* limitations under the License.
1919*/
2020
21-
2221'use strict' ;
2322
2423// MODULES //
@@ -31,23 +30,6 @@ var cwd = require( '@stdlib/process/cwd' );
3130var writeFile = require ( './../lib' ) ;
3231
3332
34- // FUNCTIONS //
35-
36- /**
37- * Callback invoked upon writing a file.
38- *
39- * @private
40- * @param {Error } [error] - error object
41- * @returns {void }
42- */
43- function onWrite ( error ) {
44- if ( error ) {
45- process . exitCode = 1 ;
46- return console . error ( 'Error: %s' , error . message ) ; // eslint-disable-line no-console
47- }
48- }
49-
50-
5133// MAIN //
5234
5335/**
@@ -72,12 +54,15 @@ function main() {
7254 } )
7355 } ) ;
7456
57+ // Get any provided command-line options:
58+ flags = cli . flags ( ) ;
59+ if ( flags . help || flags . version ) {
60+ return ;
61+ }
62+
7563 // Get any provided command-line arguments:
7664 args = cli . args ( ) ;
7765
78- // Get any provided command-line flags:
79- flags = cli . flags ( ) ;
80-
8166 opts = { } ;
8267 if ( flags . encoding ) {
8368 opts . encoding = flags . encoding ;
@@ -103,11 +88,23 @@ function main() {
10388 */
10489 function onRead ( error , data ) {
10590 if ( error ) {
106- process . exitCode = 1 ;
107- return console . error ( 'Error: %s' , error . message ) ; // eslint-disable-line no-console
91+ return cli . error ( error ) ;
10892 }
10993 writeFile ( fpath , data , opts , onWrite ) ;
11094 }
95+
96+ /**
97+ * Callback invoked upon writing a file.
98+ *
99+ * @private
100+ * @param {Error } [error] - error object
101+ * @returns {void }
102+ */
103+ function onWrite ( error ) {
104+ if ( error ) {
105+ return cli . error ( error ) ;
106+ }
107+ }
111108}
112109
113110main ( ) ;
0 commit comments