Skip to content

Commit 88405e6

Browse files
committed
chore(readyaml): loop through default config paths
1 parent e2e1b4b commit 88405e6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/readYAML.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ import { resolve } from "node:path";
66
import { parse } from "yaml";
77

88
const CONFIG_VERSION = 1;
9+
const DEFAULT_YAML_PATHS = [ "jtr.yml", "jtr.yaml" ];
10+
911
const rkebab = /-([a-z])/g;
1012

1113
export default async function readYAML( path ) {
1214
if ( !path ) {
13-
if ( await stat( resolve( process.cwd(), "jtr.yml" ) ).catch( () => false ) ) {
14-
path = "jtr.yml";
15-
} else if ( await stat( resolve( process.cwd(), "jtr.yaml" ) ).catch( () => false ) ) {
16-
path = "jtr.yaml";
17-
} else {
18-
return {};
15+
for ( const defaultPath of DEFAULT_YAML_PATHS ) {
16+
if ( await stat( resolve( process.cwd(), defaultPath ) ).catch( () => false ) ) {
17+
path = defaultPath;
18+
}
1919
}
2020
}
21+
if ( !path ) {
22+
return {};
23+
}
2124

2225
const contents = await readFile( resolve( process.cwd(), path ), "utf8" );
2326
let config = await parse( contents );

0 commit comments

Comments
 (0)