summaryrefslogtreecommitdiffstats
path: root/node_modules/webpack-cli/bin/utils/validate-options.js
blob: 4452e54650ebc7374156ddce7b96b6e0131e5261 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const webpackConfigurationSchema = require("../config/webpackConfigurationSchema.json");
const validateSchema = require("webpack").validateSchema;

module.exports = function validateOptions(options) {
	let error;
	try {
		const errors = validateSchema(webpackConfigurationSchema, options);
		if (errors && errors.length > 0) {
			const { WebpackOptionsValidationError } = require("webpack");
			error = new WebpackOptionsValidationError(errors);
		}
	} catch (err) {
		error = err;
	}

	if (error) {
		console.error(error.message);
		// eslint-disable-next-line no-process-exit
		process.exit(-1);
	}
};