Skip to content

Commit

Permalink
feat: [577] Add yml support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkrum committed Apr 20, 2024
1 parent c94d3d7 commit c4d8a21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Options> = DEFAULT_OPTIONS): Promise<string> {
Expand All @@ -124,7 +124,7 @@ export function compileFromFile(filename: string, options: Partial<Options> = DE

if (isYml(filename)) {
schema = Try<JSONSchema4>(
() => JSON.parse(JSON.stringify(yaml.load(contents.toString()))),
() => yaml.load(contents.toString()) as JSONSchema4,
() => {
throw new TypeError(`Error parsing YML in file "${filename}"`)
},
Expand Down

0 comments on commit c4d8a21

Please sign in to comment.