Skip to content

Commit 47f5a03

Browse files
committed
test: fix
1 parent 06c700a commit 47f5a03

File tree

9 files changed

+450
-424
lines changed

9 files changed

+450
-424
lines changed

packages/webpack-cli/src/webpack-cli.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ import {
1313
WebpackCLICommandOptions,
1414
WebpackCLIMainOption,
1515
WebpackCLILogger,
16-
WebpackV4LegacyStats,
1716
WebpackDevServerOptions,
1817
WebpackRunOptions,
19-
WebpackV4Compiler,
2018
WebpackCompiler,
2119
WebpackConfiguration,
2220
Argv,
@@ -34,7 +32,6 @@ import {
3432
Instantiable,
3533
JsonExt,
3634
ModuleName,
37-
MultipleCompilerStatsOptions,
3835
PackageInstallOptions,
3936
PackageManager,
4037
Path,
@@ -2092,6 +2089,23 @@ class WebpackCLI implements IWebpackCLI {
20922089
item.stats = { preset: item.stats };
20932090
}
20942091

2092+
let colors;
2093+
2094+
// From arguments
2095+
if (typeof this.isColorSupportChanged !== "undefined") {
2096+
colors = Boolean(this.isColorSupportChanged);
2097+
}
2098+
// From stats
2099+
else if (typeof (item.stats as StatsOptions).colors !== "undefined") {
2100+
colors = (item.stats as StatsOptions).colors;
2101+
}
2102+
// Default
2103+
else {
2104+
colors = Boolean(this.colors.isColorSupported);
2105+
}
2106+
2107+
item.stats.colors = colors;
2108+
20952109
// Apply CLI plugin
20962110
if (!item.plugins) {
20972111
item.plugins = [];

test/build/core-flags/core-flags.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,17 @@ describe("core flags", () => {
239239
expect(stdout).toContain(`devtool: 'source-map'`);
240240
});
241241

242-
it("should allow string value devtool option using alias", async () => {
242+
// TODO: Enable alias with webpack 5
243+
it.skip("should allow string value devtool option using alias", async () => {
243244
const { exitCode, stderr, stdout } = await run(__dirname, ["-d", "source-map"]);
244245

245246
expect(exitCode).toBe(0);
246247
expect(stderr).toBeFalsy();
247248
expect(stdout).toContain(`devtool: 'source-map'`);
248249
});
249250

250-
it("should allow string value devtool option using alias #1", async () => {
251+
// TODO: Enable alias with webpack 5
252+
it.skip("should allow string value devtool option using alias #1", async () => {
251253
// cSpell:ignore dsource
252254
const { exitCode, stderr, stdout } = await run(__dirname, ["-dsource-map"]);
253255

test/build/defaults/output-defaults.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("output flag defaults", () => {
3838
]);
3939

4040
expect(exitCode).toBe(2);
41-
expect(stderr).toContain("Error: Option '-o, --output-path <value>' argument missing");
41+
expect(stderr).toContain("Error: Option '--output-path <value>' argument missing");
4242
expect(stdout).toBeFalsy();
4343
});
4444
});

test/build/devtool/object/source-map-object.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("source-map object", () => {
3434
it("should override config with source-map", async () => {
3535
const { exitCode, stderr, stdout } = await run(
3636
__dirname,
37-
["-c", "./webpack.eval.config.js", "--devtool", "source-map", "-o", "./binary"],
37+
["-c", "./webpack.eval.config.js", "--devtool", "source-map", "--output-path", "./binary"],
3838
false,
3939
);
4040

@@ -47,7 +47,7 @@ describe("source-map object", () => {
4747
it("should override config with devtool false", async () => {
4848
const { exitCode, stderr, stdout } = await run(
4949
__dirname,
50-
["-c", "./webpack.eval.config.js", "--no-devtool", "-o", "./binary"],
50+
["-c", "./webpack.eval.config.js", "--no-devtool", "--output-path", "./binary"],
5151
false,
5252
);
5353

test/build/entry/flag-entry/entry-with-flag.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ const { resolve } = require("path");
66

77
describe("entry flag", () => {
88
it("should resolve the path to src/index.cjs", async () => {
9-
const { exitCode, stderr, stdout } = await run(__dirname, [
10-
"--entry",
11-
"./src/index.cjs",
12-
"-o",
13-
"./dist/",
14-
]);
9+
const { exitCode, stderr, stdout } = await run(__dirname, ["--entry", "./src/index.cjs"]);
1510

1611
expect(exitCode).toBe(0);
1712
expect(stderr).toBeFalsy();

test/build/output/__snapshots__/output-named-bundles.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`output flag named bundles should output file in bin directory using default webpack config with warning for empty output value: stderr 1`] = `
4-
"[webpack-cli] Error: Option '-o, --output-path <value>' argument missing
4+
"[webpack-cli] Error: Option '--output-path <value>' argument missing
55
[webpack-cli] Run 'webpack --help' to see available commands and options"
66
`;
77

test/build/target/flag-test/target-flag.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ describe("--target flag", () => {
2222
expect(stdout).toContain(`target: [ '${val}' ]`);
2323
});
2424

25-
it(`should accept ${val} with -t alias`, async () => {
25+
// TODO: Enable aliases with webpack 5
26+
it.skip(`should accept ${val} with -t alias`, async () => {
2627
const { exitCode, stderr, stdout } = await run(__dirname, ["-t", `${val}`]);
2728

2829
expect(exitCode).toBe(0);

test/build/target/flag-test/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
33
module.exports = {
44
entry: "./index.js",
55
mode: "development",
6-
target: "node",
76
plugins: [new WebpackCLITestPlugin()],
87
};

0 commit comments

Comments
 (0)