diff --git a/src/index.ts b/src/index.ts index 712ee182..d8aa181e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,7 +109,7 @@ export const DEFAULT_OPTIONS: Options = { } function isYml(filename: string) { - return filename.split('.').pop() === 'yml' + return filename.endsWith('.yaml') || filename.endsWith('.yml') } export function compileFromFile(filename: string, options: Partial = DEFAULT_OPTIONS): Promise { @@ -124,7 +124,7 @@ export function compileFromFile(filename: string, options: Partial = DE if (isYml(filename)) { schema = Try( - () => JSON.parse(JSON.stringify(yaml.load(contents.toString()))), + () => yaml.load(contents.toString()) as JSONSchema4, () => { throw new TypeError(`Error parsing YML in file "${filename}"`) },