@@ -5,8 +5,10 @@ import json5 from 'json5'
55import  fault  from  'fault' 
66import  { schema }  from  './schema.js' 
77
8+ const  own  =  { } . hasOwnProperty 
9+ 
810// Schema for `minimist`. 
9- var  minischema  =  { 
11+ const  minischema  =  { 
1012  unknown : handleUnknownArgument , 
1113  default : { } , 
1214  alias : { } , 
@@ -21,12 +23,9 @@ while (++index < schema.length) {
2123
2224// Parse CLI options. 
2325export  function  options ( flags ,  configuration )  { 
24-   var  extension  =  configuration . extensions [ 0 ] 
25-   var  name  =  configuration . name 
26-   var  config  =  toCamelCase ( minimist ( flags ,  minischema ) ) 
27-   var  help 
28-   var  ext 
29-   var  report 
26+   const  extension  =  configuration . extensions [ 0 ] 
27+   const  name  =  configuration . name 
28+   const  config  =  toCamelCase ( minimist ( flags ,  minischema ) ) 
3029  let  index  =  - 1 
3130
3231  while  ( ++ index  <  schema . length )  { 
@@ -36,10 +35,9 @@ export function options(flags, configuration) {
3635    } 
3736  } 
3837
39-   ext  =  commaSeparated ( config . ext ) 
40-   report  =  reporter ( config . report ) 
41- 
42-   help  =  [ 
38+   const  ext  =  commaSeparated ( config . ext ) 
39+   const  report  =  reporter ( config . report ) 
40+   const  help  =  [ 
4341    inspectAll ( schema ) , 
4442    '' , 
4543    'Examples:' , 
@@ -94,7 +92,7 @@ export function options(flags, configuration) {
9492} 
9593
9694function  addEach ( option )  { 
97-   var  value  =  option . default 
95+   const  value  =  option . default 
9896
9997  minischema . default [ option . long ]  =  value  ===  undefined  ? null  : value 
10098
@@ -114,7 +112,7 @@ function commaSeparated(value) {
114112
115113// Parse `plugins`. 
116114function  plugins ( value )  { 
117-   var  result  =  { } 
115+   const  result  =  { } 
118116  const  normalized  =  normalize ( value ) . map ( ( d )  =>  splitOptions ( d ) ) 
119117  let  index  =  - 1 
120118
@@ -128,9 +126,9 @@ function plugins(value) {
128126
129127// Parse `reporter`: only one is accepted. 
130128function  reporter ( value )  { 
131-   var  all  =  normalize ( value ) 
129+   const  all  =  normalize ( value ) 
132130    . map ( ( d )  =>  splitOptions ( d ) ) 
133-     . map ( function   ( value )  { 
131+     . map ( ( value )   =>  { 
134132      return  [ value [ 0 ] ,  value [ 1 ]  ? parseConfig ( value [ 1 ] ,  { } )  : null ] 
135133    } ) 
136134
@@ -139,7 +137,7 @@ function reporter(value) {
139137
140138// Parse `settings`. 
141139function  settings ( value )  { 
142-   var  cache  =  { } 
140+   const  cache  =  { } 
143141  const  normalized  =  normalize ( value ) 
144142  let  index  =  - 1 
145143
@@ -152,8 +150,8 @@ function settings(value) {
152150
153151// Parse configuration. 
154152function  parseConfig ( flags ,  cache )  { 
155-   var  flag 
156-   var  message 
153+   let  flag 
154+   let  message 
157155
158156  try  { 
159157    flags  =  toCamelCase ( parseJSON ( flags ) ) 
@@ -165,7 +163,9 @@ function parseConfig(flags, cache) {
165163  } 
166164
167165  for  ( flag  in  flags )  { 
168-     cache [ flag ]  =  flags [ flag ] 
166+     if  ( own . call ( flags ,  flag ) )  { 
167+       cache [ flag ]  =  flags [ flag ] 
168+     } 
169169  } 
170170
171171  return  cache 
@@ -208,8 +208,8 @@ function inspectAll(options) {
208208
209209// Inspect one `option`. 
210210function  inspect ( option )  { 
211-   var  description  =  option . description 
212-   var  long  =  option . long 
211+   let  description  =  option . description 
212+   let  long  =  option . long 
213213
214214  if  ( option . default  ===  true  ||  option . truelike )  { 
215215    description  +=  ' (on by default)' 
@@ -253,18 +253,20 @@ function splitList(value) {
253253
254254// Transform the keys on an object to camel-case, recursivly. 
255255function  toCamelCase ( object )  { 
256-   var  result  =  { } 
257-   var  value 
258-   var  key 
256+   const  result  =  { } 
257+   let  value 
258+   let  key 
259259
260260  for  ( key  in  object )  { 
261-     value  =  object [ key ] 
261+     if  ( own . call ( object ,  key ) )  { 
262+       value  =  object [ key ] 
262263
263-     if  ( value  &&  typeof  value  ===  'object'  &&  ! ( 'length'  in  value ) )  { 
264-       value  =  toCamelCase ( value ) 
265-     } 
264+        if  ( value  &&  typeof  value  ===  'object'  &&  ! ( 'length'  in  value ) )  { 
265+          value  =  toCamelCase ( value ) 
266+        } 
266267
267-     result [ camelcase ( key ) ]  =  value 
268+       result [ camelcase ( key ) ]  =  value 
269+     } 
268270  } 
269271
270272  return  result 
0 commit comments