source: imaps-frontend/node_modules/@webpack-cli/configtest/lib/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[79a0317]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack";
4class ConfigTestCommand {
5 async apply(cli) {
6 await cli.makeCommand({
7 name: "configtest [config-path]",
8 alias: "t",
9 description: "Validate a webpack configuration.",
10 pkg: "@webpack-cli/configtest",
11 dependencies: [WEBPACK_PACKAGE],
12 }, [], async (configPath) => {
13 cli.webpack = await cli.loadWebpack();
14 const config = await cli.loadConfig(configPath ? { config: [configPath] } : {});
15 const configPaths = new Set();
16 if (Array.isArray(config.options)) {
17 config.options.forEach((options) => {
18 const loadedConfigPaths = config.path.get(options);
19 if (loadedConfigPaths) {
20 loadedConfigPaths.forEach((path) => configPaths.add(path));
21 }
22 });
23 }
24 else {
25 if (config.path.get(config.options)) {
26 const loadedConfigPaths = config.path.get(config.options);
27 if (loadedConfigPaths) {
28 loadedConfigPaths.forEach((path) => configPaths.add(path));
29 }
30 }
31 }
32 if (configPaths.size === 0) {
33 cli.logger.error("No configuration found.");
34 process.exit(2);
35 }
36 cli.logger.info(`Validate '${Array.from(configPaths).join(" ,")}'.`);
37 try {
38 cli.webpack.validate(config.options);
39 }
40 catch (error) {
41 if (cli.isValidationError(error)) {
42 cli.logger.error(error.message);
43 }
44 else {
45 cli.logger.error(error);
46 }
47 process.exit(2);
48 }
49 cli.logger.success("There are no validation errors in the given webpack configuration.");
50 });
51 }
52}
53exports.default = ConfigTestCommand;
Note: See TracBrowser for help on using the repository browser.