@@ -69,9 +69,11 @@ YargsParser.command(
69
69
watch : argv . watch as boolean ,
70
70
templateFileName : argv . template as string ,
71
71
templateOptions : argv . templateOptions || { } ,
72
- redocOptions : argv . options || { } ,
72
+ redocOptions : getObjectOrJSON ( argv . options ) ,
73
73
} ;
74
74
75
+ console . log ( config ) ;
76
+
75
77
try {
76
78
await serve ( argv . port as number , argv . spec as string , config ) ;
77
79
} catch ( e ) {
@@ -124,7 +126,7 @@ YargsParser.command(
124
126
disableGoogleFont : argv . disableGoogleFont as boolean ,
125
127
templateFileName : argv . template as string ,
126
128
templateOptions : argv . templateOptions || { } ,
127
- redocOptions : argv . options || { } ,
129
+ redocOptions : getObjectOrJSON ( argv . options ) ,
128
130
} ;
129
131
130
132
try {
@@ -353,3 +355,15 @@ function handleError(error: Error) {
353
355
console . error ( error . stack ) ;
354
356
process . exit ( 1 ) ;
355
357
}
358
+
359
+ function getObjectOrJSON ( options ) {
360
+ try {
361
+ return options && typeof options === 'string'
362
+ ? JSON . parse ( options ) : options
363
+ ? options
364
+ : { } ;
365
+ } catch ( e ) {
366
+ console . log ( `Encountered error:\n${ options } \nis not a valid JSON.` ) ;
367
+ handleError ( e ) ;
368
+ }
369
+ }
0 commit comments