/
index.ts
33 lines (27 loc) · 1.03 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { validate } from 'webpack';
class ConfigTestCommand {
async apply(cli): Promise<void> {
const { logger } = cli;
await cli.makeCommand(
{
name: 'configtest <config-path>',
alias: 't',
description: 'Test your webpack configuration against validation errors.',
usage: '[configs]',
pkg: '@webpack-cli/configtest',
},
[],
async (configPath: string) => {
const { options } = await cli.resolveConfig({ config: [configPath] });
//eslint-disable-next-line @typescript-eslint/no-explicit-any
const validationErrors: any = validate(options);
if (validationErrors) {
logger.error(validationErrors);
process.exit(2);
}
logger.success('There are no validation errors in the given webpack configuration.');
},
);
}
}
export default ConfigTestCommand;