import fs from 'fs' ; import jsonValidator from 'is-my-json-valid' ; import * as yaml from 'js-yaml' ; import type { Document } from './schema' ; import * as schema from './schema.json' ; const schemaValidator = jsonValidator ( schema as any ) ; export function validateDocument ( document ) { if ( ! schemaValidator ( document ) ) { return ; } return document as Document ; } export function loadDocumentSync ( file ) { return yaml . load ( fs . readFileSync ( file , 'utf8' ) ) ; }