mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-09 06:34:53 +03:00
added support for JSON string for --options cli argument
This commit is contained in:
parent
8632b193b2
commit
2e735d1bff
17
cli/index.ts
17
cli/index.ts
|
@ -64,14 +64,18 @@ YargsParser.command(
|
|||
return yargs;
|
||||
},
|
||||
async argv => {
|
||||
const redocOptions = getRedocOptions(argv.options);
|
||||
|
||||
const config: Options = {
|
||||
ssr: argv.ssr as boolean,
|
||||
watch: argv.watch as boolean,
|
||||
templateFileName: argv.template as string,
|
||||
templateOptions: argv.templateOptions || {},
|
||||
redocOptions: argv.options || {},
|
||||
redocOptions,
|
||||
};
|
||||
|
||||
console.log(config);
|
||||
|
||||
try {
|
||||
await serve(argv.port as number, argv.spec as string, config);
|
||||
} catch (e) {
|
||||
|
@ -116,6 +120,8 @@ YargsParser.command(
|
|||
return yargs;
|
||||
},
|
||||
async (argv: any) => {
|
||||
const redocOptions = getRedocOptions(argv.options);
|
||||
|
||||
const config = {
|
||||
ssr: true,
|
||||
output: argv.o as string,
|
||||
|
@ -124,7 +130,7 @@ YargsParser.command(
|
|||
disableGoogleFont: argv.disableGoogleFont as boolean,
|
||||
templateFileName: argv.template as string,
|
||||
templateOptions: argv.templateOptions || {},
|
||||
redocOptions: argv.options || {},
|
||||
redocOptions,
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -353,3 +359,10 @@ function handleError(error: Error) {
|
|||
console.error(error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function getRedocOptions(options) {
|
||||
return options && typeof options === 'string'
|
||||
? JSON.parse(options) : options
|
||||
? options
|
||||
: {};
|
||||
}
|
Loading…
Reference in New Issue
Block a user