File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,27 @@ import { resolve } from "node:path";
6
6
import { parse } from "yaml" ;
7
7
8
8
const CONFIG_VERSION = 1 ;
9
+ const rkebab = / - ( [ a - z ] ) / g;
9
10
10
11
export default async function readYAML ( path ) {
11
12
if ( ! path ) {
12
13
return { } ;
13
14
}
14
15
15
16
const contents = await readFile ( resolve ( process . cwd ( ) , path ) , "utf8" ) ;
16
- const config = await parse ( contents ) ;
17
+ let config = await parse ( contents ) ;
17
18
18
19
if ( config . version !== CONFIG_VERSION ) {
19
20
throw new Error ( `Invalid configuration version. Expected ${ CONFIG_VERSION } .` ) ;
20
21
}
22
+
23
+ // Convert kebab-case keys to camelCase
24
+ config = Object . fromEntries (
25
+ Object . entries ( config ) . map ( ( [ key , value ] ) => [
26
+ key . replace ( rkebab , ( _ , letter ) => letter . toUpperCase ( ) ) ,
27
+ value
28
+ ] )
29
+ ) ;
30
+
21
31
return config ;
22
32
}
You can’t perform that action at this time.
0 commit comments