Skip to content

Commit c4d8a21

Browse files
committed
feat: [577] Add yml support
1 parent c94d3d7 commit c4d8a21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const DEFAULT_OPTIONS: Options = {
109109
}
110110

111111
function isYml(filename: string) {
112-
return filename.split('.').pop() === 'yml'
112+
return filename.endsWith('.yaml') || filename.endsWith('.yml')
113113
}
114114

115115
export function compileFromFile(filename: string, options: Partial<Options> = DEFAULT_OPTIONS): Promise<string> {
@@ -124,7 +124,7 @@ export function compileFromFile(filename: string, options: Partial<Options> = DE
124124

125125
if (isYml(filename)) {
126126
schema = Try<JSONSchema4>(
127-
() => JSON.parse(JSON.stringify(yaml.load(contents.toString()))),
127+
() => yaml.load(contents.toString()) as JSONSchema4,
128128
() => {
129129
throw new TypeError(`Error parsing YML in file "${filename}"`)
130130
},

0 commit comments

Comments
 (0)