Skip to content

Commit 83489d2

Browse files
committed
conditionally set the 'mode' property in integration tests depending on webpack version
1 parent 0100a00 commit 83489d2

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

test/integration/index.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var path = require('path');
66
var webpack = require('webpack');
77
var ForkTsCheckerWebpackPlugin = require('../../lib/index');
88

9+
var webpackMajorVersion = require('./webpackVersion')();
10+
911
describe('[INTEGRATION] index', function () {
1012
this.timeout(30000);
1113
var plugin;
@@ -18,7 +20,7 @@ describe('[INTEGRATION] index', function () {
1820
: { transpileOnly: true, silent: true };
1921

2022
return webpack({
21-
mode: 'development',
23+
...(webpackMajorVersion >= 4 ? { mode: 'development' } : {}),
2224
context: path.resolve(__dirname, './project'),
2325
entry: './src/index.ts',
2426
output: {

test/integration/vue.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var process = require('process');
88
var ForkTsCheckerWebpackPlugin = require('../../lib/index');
99
var IncrementalChecker = require('../../lib/IncrementalChecker');
1010

11+
var webpackMajorVersion = require('./webpackVersion')();
12+
1113
describe('[INTEGRATION] vue', function () {
1214
this.timeout(30000);
1315
process.setMaxListeners(20);
@@ -20,7 +22,7 @@ describe('[INTEGRATION] vue', function () {
2022
plugin = new ForkTsCheckerWebpackPlugin(Object.assign({}, options, { silent: true }));
2123

2224
compiler = webpack({
23-
mode: 'development',
25+
...(webpackMajorVersion >= 4 ? { mode: 'development' } : {}),
2426
context: path.resolve(__dirname, './vue'),
2527
entry: './src/index.ts',
2628
output: {

test/integration/webpackVersion.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function getWebpackMajorVersion() {
2+
// Determine major webpack version from package.json
3+
var packageJson = require('../../package.json');
4+
var webpackVersion = packageJson.devDependencies.webpack.replace(
5+
/[^0-9.]/g,
6+
''
7+
);
8+
var webpackMajorVersion = parseInt(webpackVersion.split('.')[0], 10);
9+
return webpackMajorVersion;
10+
}
11+
12+
module.exports = getWebpackMajorVersion;

0 commit comments

Comments
 (0)