Skip to content

Commit e400f17

Browse files
author
Michael Pratt
committed
Update for Node 4 use to prevent major semver bump
1 parent c821025 commit e400f17

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

.eslintrc.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
extends: airbnb-base
22
plugins:
33
- import
4+
5+
parserOptions:
6+
ecmaVersion: 5
7+
8+
env:
9+
node: true
10+
browser: false
11+
es6: false
12+
413
rules:
514
no-console: off
615
func-names: off
716
max-len: off
817
no-confusing-arrow: off
18+
object-shorthand: off

.travis.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22

33
node_js:
4-
- "node"
4+
- "10"
55
- "8"
66
- "6"
77
- "4"
@@ -16,11 +16,6 @@ env:
1616
- WEBPACK_VERSION=3
1717
- WEBPACK_VERSION=4
1818

19-
matrix:
20-
exclude:
21-
- node_js: "4"
22-
env: WEBPACK_VERSION=4
23-
2419
install:
2520
- npm install
2621
- npm rm webpack

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ CaseSensitivePathsPlugin.prototype.apply = function (compiler) {
186186
if (resolvedFilesCount === compilation.fileDependencies.size) {
187187
if (errors.length) {
188188
// Send all errors to webpack
189-
compilation.errors.push(...errors);
189+
Array.prototype.push.apply(compilation.errors, errors);
190190
}
191191
callback();
192192
}

test/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const webpackPkg = require('webpack/package.json');
1313

1414
const CaseSensitivePathsPlugin = require('../');
1515

16-
function webpackCompilerAtDir(dir, otherOpts) {
16+
function webpackCompilerAtDir(dir, otherOpts, useBeforeEmitHook) {
1717
const opts = Object.assign({
1818
context: path.join(__dirname, 'fixtures', dir),
1919
entry: './entry',
@@ -22,7 +22,9 @@ function webpackCompilerAtDir(dir, otherOpts) {
2222
filename: 'result.js',
2323
},
2424
plugins: [
25-
new CaseSensitivePathsPlugin(),
25+
new CaseSensitivePathsPlugin({
26+
useBeforeEmitHook: useBeforeEmitHook,
27+
}),
2628
],
2729
}, otherOpts);
2830

@@ -56,6 +58,26 @@ describe('CaseSensitivePathsPlugin', () => {
5658
done();
5759
});
5860
});
61+
62+
it('should handle errors correctly in emit hook mode', (done) => {
63+
const compiler = webpackCompilerAtDir('wrong-case', {}, true);
64+
65+
compiler.run((err, stats) => {
66+
if (err) done(err);
67+
assert(stats.hasErrors());
68+
assert.equal(stats.hasWarnings(), false);
69+
const jsonStats = stats.toJson();
70+
assert.equal(jsonStats.errors.length, 1);
71+
72+
const error = jsonStats.errors[0];
73+
// check that the plugin produces the correct output
74+
assert(error.indexOf('[CaseSensitivePathsPlugin]') > -1);
75+
assert(error.indexOf('ExistingTestFile.js') > -1); // wrong file require
76+
assert(error.indexOf('existingTestFile.js') > -1); // actual file name
77+
78+
done();
79+
});
80+
});
5981
}
6082

6183
// For future reference: This test is somewhat of a race condition, these values seem to work well.

0 commit comments

Comments
 (0)