Skip to content

Commit e67af52

Browse files
ci: refactor (webpack-contrib#830)
1 parent acf5722 commit e67af52

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

.github/workflows/nodejs.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ jobs:
9090

9191
- name: Run tests for webpack version ${{ matrix.webpack-version }}
9292
run: npm run test:coverage -- --ci
93+
env:
94+
EXPERIMENTAL_USE_IMPORT_MODULE: "false"
9395

9496
- name: Submit coverage data to codecov
9597
uses: codecov/codecov-action@v1
9698
with:
9799
token: ${{ secrets.CODECOV_TOKEN }}
98100

99-
test2:
101+
test-new-api:
100102
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack latest, experimentalUseImportModule
101103

102104
strategy:

test/TestCases.test.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import webpack from "webpack";
99

1010
import Self from "../src/index";
1111

12+
import yn from "./helpers/yn";
13+
1214
function clearDirectory(dirPath) {
1315
let files;
1416

@@ -128,9 +130,12 @@ describe("TestCases", () => {
128130
config.plugins.map((p) => {
129131
if (p.constructor === Self) {
130132
const { options } = p;
131-
options.experimentalUseImportModule =
132-
!!process.env.EXPERIMENTAL_USE_IMPORT_MODULE;
133+
134+
options.experimentalUseImportModule = yn(
135+
process.env.EXPERIMENTAL_USE_IMPORT_MODULE
136+
);
133137
}
138+
134139
return p;
135140
}),
136141
},
@@ -192,7 +197,9 @@ describe("TestCases", () => {
192197
const expectedDirectoryByVersion = path.join(
193198
expectedDirectory,
194199
`webpack-${webpack.version[0]}${
195-
process.env.EXPERIMENTAL_USE_IMPORT_MODULE ? "-importModule" : ""
200+
yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE)
201+
? "-importModule"
202+
: ""
196203
}`
197204
);
198205

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
module.exports = () => !process.env.EXPERIMENTAL_USE_IMPORT_MODULE;
1+
import yn from "../../helpers/yn";
2+
3+
module.exports = () => !yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE);

test/helpers/yn.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function yn(value, defaultValue = false) {
2+
if (/^(?:y|yes|true|1|on)$/i.test(value)) {
3+
return true;
4+
}
5+
6+
if (/^(?:n|no|false|0|off)$/i.test(value)) {
7+
return false;
8+
}
9+
10+
return defaultValue;
11+
}
12+
13+
module.exports = yn;

0 commit comments

Comments
 (0)