Skip to content

Commit eb51da5

Browse files
committed
refactor: update cli-config.schema
1 parent db1917e commit eb51da5

2 files changed

Lines changed: 225 additions & 246 deletions

File tree

lib/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Package from "#lib/package";
1111

1212
env.loadUserEnv();
1313

14-
const validateCliConfig = new Ajv().compileFile( import.meta.resolve( "#resources/schemas/cli.config.schema.yaml" ) ),
14+
const cliConfigSchema = new Ajv().addSchema( await readConfig( import.meta.resolve( "#resources/schemas/cli.config.schema.yaml" ) ) ),
1515
defaultCliConfig = await readConfig( "#resources/cli.config.yaml", { "resolve": import.meta.url } );
1616

1717
export function getLintReportTable ( options = {} ) {
@@ -103,7 +103,7 @@ export function getCliConfig ( path, { validate = true } = {} ) {
103103
const cliConfig = mergeObjects( {}, defaultCliConfig, readConfigSync( path ) );
104104

105105
if ( validate ) {
106-
if ( !validateCliConfig( cliConfig ) ) throw `CLI config is not valid:\n${ validateCliConfig.errors }`;
106+
if ( !cliConfigSchema.validate( "config", cliConfig ) ) throw `CLI config is not valid:\n${ cliConfigSchema.errors }`;
107107
}
108108

109109
return cliConfig;

0 commit comments

Comments
 (0)