Output json-schema in CLI

master
Paul Loyd 2017-12-16 17:03:22 +03:00
parent df240ba87f
commit 15f4d9459d
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import * as yaml from 'yaml-js'; import * as yaml from 'yaml-js';
import * as optimist from 'optimist'; import * as optimist from 'optimist';
import stringifyJson from 'json-stringify-pretty-compact';
import collect from '.'; import collect from '.';
@ -15,14 +16,16 @@ function run(path: string) {
} }
try { try {
const {types} = collect(path); const {types, schema} = collect(path);
const output = yaml.dump(types, null, null, { const output = yaml.dump(types, null, null, {
indent: 4, indent: 4,
width: 100, width: 80,
}); });
console.log(output.trimRight()); console.log(output.trimRight());
console.log('--------');
console.log(stringifyJson(schema, {maxLength: 80}));
} catch (ex) { } catch (ex) {
console.error(ex.message); console.error(ex.message);
console.error(ex.stack); console.error(ex.stack);