Skip to content

Commit

Permalink
fix: configtest logic
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Aug 21, 2021
1 parent 463bf5e commit 2186874
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/configtest/src/index.ts
Expand Up @@ -11,6 +11,8 @@ class ConfigTestCommand {
},
[],
async (configPath: string | undefined): Promise<void> => {
cli.webpack = await cli.loadWebpack();

const config = await cli.resolveConfig(configPath ? { config: [configPath] } : {});
const configPaths = new Set<string>();

Expand All @@ -33,18 +35,19 @@ class ConfigTestCommand {

cli.logger.info(`Validate '${Array.from(configPaths).join(" ,")}'.`);

const webpack = await cli.loadWebpack();

try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const error: any = webpack.validate(config.options);
const error: any = cli.webpack.validate(config.options);

// TODO remove this after drop webpack@4
if (error && error.length > 0) {
throw new webpack.WebpackOptionsValidationError(error);
throw new cli.webpack.WebpackOptionsValidationError(error);
}
} catch (error) {
if (cli.isValidationError(error)) {
if (
error instanceof cli.webpack.ValidationError ||
error.name === "ValidationError"
) {
cli.logger.error(error.message);
} else {
cli.logger.error(error);
Expand Down

0 comments on commit 2186874

Please sign in to comment.