@@ -9,13 +9,13 @@ const fs = require('fs');
9
9
const args = process . argv . slice ( 2 ) ;
10
10
let format = 'json' ;
11
11
let template = null ;
12
- let inputFile = null ;
12
+ let filename = null ;
13
13
let nodeVersion = null ;
14
14
let analytics = null ;
15
15
16
16
args . forEach ( function ( arg ) {
17
17
if ( ! arg . startsWith ( '--' ) ) {
18
- inputFile = arg ;
18
+ filename = arg ;
19
19
} else if ( arg . startsWith ( '--format=' ) ) {
20
20
format = arg . replace ( / ^ - - f o r m a t = / , '' ) ;
21
21
} else if ( arg . startsWith ( '--template=' ) ) {
@@ -29,42 +29,33 @@ args.forEach(function(arg) {
29
29
30
30
nodeVersion = nodeVersion || process . version ;
31
31
32
- if ( ! inputFile ) {
32
+ if ( ! filename ) {
33
33
throw new Error ( 'No input file specified' ) ;
34
34
}
35
35
36
- console . error ( 'Input file = %s' , inputFile ) ;
37
- fs . readFile ( inputFile , 'utf8' , function ( er , input ) {
36
+ console . error ( 'Input file = %s' , filename ) ;
37
+ fs . readFile ( filename , 'utf8' , ( er , input ) => {
38
38
if ( er ) throw er ;
39
39
// process the input for @include lines
40
- processIncludes ( inputFile , input , next ) ;
40
+ processIncludes ( filename , input , next ) ;
41
41
} ) ;
42
42
43
43
function next ( er , input ) {
44
44
if ( er ) throw er ;
45
45
switch ( format ) {
46
46
case 'json' :
47
- require ( './json.js' ) ( input , inputFile , function ( er , obj ) {
47
+ require ( './json.js' ) ( input , filename , ( er , obj ) => {
48
48
console . log ( JSON . stringify ( obj , null , 2 ) ) ;
49
49
if ( er ) throw er ;
50
50
} ) ;
51
51
break ;
52
52
53
53
case 'html' :
54
- require ( './html.js' ) (
55
- {
56
- input : input ,
57
- filename : inputFile ,
58
- template : template ,
59
- nodeVersion : nodeVersion ,
60
- analytics : analytics ,
61
- } ,
62
-
63
- function ( er , html ) {
64
- if ( er ) throw er ;
65
- console . log ( html ) ;
66
- }
67
- ) ;
54
+ require ( './html' ) ( { input, filename, template, nodeVersion, analytics } ,
55
+ ( err , html ) => {
56
+ if ( err ) throw err ;
57
+ console . log ( html ) ;
58
+ } ) ;
68
59
break ;
69
60
70
61
default :
0 commit comments