UNPKG

json-schema-describes-subset

Version:

Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).

19 lines 776 B
import fs from 'fs/promises'; import process from 'process'; import path from 'path'; import { resolveConfig, format } from 'prettier'; import { toPosix } from '../to-posix/index.js'; export async function formatFileContent(filepath, fileContent) { const options = await resolveConfig(filepath); return await format(fileContent, { ...options?.default, // seems to be a bug with tsx ...options, filepath, }); } export async function writeFormattedFile(filepath, fileContent) { await fs.writeFile(filepath, await formatFileContent(filepath, fileContent), 'utf-8'); // eslint-disable-next-line no-console console.log(`wrote formatted file ./${toPosix(path.relative(process.cwd(), filepath))}`); } //# sourceMappingURL=format.js.map