import { promises as fs } from 'fs'; | ||
import path from 'path'; | ||
import stringify from 'json-stable-stringify'; | ||
import prettier from 'prettier'; | ||
@@ -18,4 +19,5 @@ import { createGenerator } from 'ts-json-schema-generator'; | ||
export function format(schema, basedir) { | ||
const options = prettier.resolveConfig(basedir); | ||
return prettier.format(JSON.stringify(schema), { parser: 'json', ...options }); | ||
const stringified = stringify(schema, { space: 2 }); | ||
const prettierOptions = prettier.resolveConfig(basedir); | ||
return prettier.format(stringified, { parser: 'json', ...prettierOptions }); | ||
} | ||
@@ -22,0 +24,0 @@ export async function updateSchema({ basedir, schemaSourceRelativePath, generatedJsonSchemaRelativePath, }) { |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -37,2 +37,3 @@ "type": "module", | ||
"globby": "^12.0.0", | ||
"json-stable-stringify": "^1.0.1", | ||
"lodash": "^4.17.21", | ||
@@ -47,2 +48,3 @@ "prettier": "^2.3.2", | ||
"@types/js-yaml": "^4.0.2", | ||
"@types/json-stable-stringify": "^1.0.33", | ||
"@types/lodash": "^4.14.171", | ||
@@ -49,0 +51,0 @@ "@types/mocha": "^9.0.0", |
Sorry, the diff of this file is not supported yet
26540
1.06%256
0.79%7
16.67%29
3.57%