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";
66import { parse } from "yaml" ;
77
88const CONFIG_VERSION = 1 ;
9+ const rkebab = / - ( [ a - z ] ) / g;
910
1011export default async function readYAML ( path ) {
1112 if ( ! path ) {
1213 return { } ;
1314 }
1415
1516 const contents = await readFile ( resolve ( process . cwd ( ) , path ) , "utf8" ) ;
16- const config = await parse ( contents ) ;
17+ let config = await parse ( contents ) ;
1718
1819 if ( config . version !== CONFIG_VERSION ) {
1920 throw new Error ( `Invalid configuration version. Expected ${ CONFIG_VERSION } .` ) ;
2021 }
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+
2131 return config ;
2232}
You can’t perform that action at this time.
0 commit comments