Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: failOnWarnings option #3317

Merged
merged 8 commits into from Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/webpack-cli/src/types.ts
Expand Up @@ -210,6 +210,7 @@ interface WebpackRunOptions extends WebpackOptionsNormalized {
json?: boolean;
argv?: Argv;
env: Env;
failOnWarnings?: boolean;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/webpack-cli/src/webpack-cli.ts
Expand Up @@ -976,6 +976,16 @@ class WebpackCLI implements IWebpackCLI {
description: "Stop watching when stdin stream has ended.",
negatedDescription: "Do not stop watching when stdin stream has ended.",
},
{
name: "fail-on-warnings",
configs: [
{
type: "boolean",
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved
},
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved
],
negative: false,
description: "Stop webpack-cli process on non-zero exit code",
},
];

// Extract all the flags being exported from core.
Expand Down Expand Up @@ -2478,6 +2488,10 @@ class WebpackCLI implements IWebpackCLI {
this.logger.raw(printedStats);
}
}

if (options.failOnWarnings && stats.hasErrors()) {
process.exit(1);
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved
}
};

const env =
Expand Down