Skip to content

Commit

Permalink
Update for Node 4 use to prevent major semver bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Pratt committed Nov 29, 2018
1 parent c821025 commit e400f17
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
extends: airbnb-base
plugins:
- import

parserOptions:
ecmaVersion: 5

env:
node: true
browser: false
es6: false

rules:
no-console: off
func-names: off
max-len: off
no-confusing-arrow: off
object-shorthand: off
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

node_js:
- "node"
- "10"
- "8"
- "6"
- "4"
Expand All @@ -16,11 +16,6 @@ env:
- WEBPACK_VERSION=3
- WEBPACK_VERSION=4

matrix:
exclude:
- node_js: "4"
env: WEBPACK_VERSION=4

install:
- npm install
- npm rm webpack
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ CaseSensitivePathsPlugin.prototype.apply = function (compiler) {
if (resolvedFilesCount === compilation.fileDependencies.size) {
if (errors.length) {
// Send all errors to webpack
compilation.errors.push(...errors);
Array.prototype.push.apply(compilation.errors, errors);
}
callback();
}
Expand Down
26 changes: 24 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const webpackPkg = require('webpack/package.json');

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

function webpackCompilerAtDir(dir, otherOpts) {
function webpackCompilerAtDir(dir, otherOpts, useBeforeEmitHook) {
const opts = Object.assign({
context: path.join(__dirname, 'fixtures', dir),
entry: './entry',
Expand All @@ -22,7 +22,9 @@ function webpackCompilerAtDir(dir, otherOpts) {
filename: 'result.js',
},
plugins: [
new CaseSensitivePathsPlugin(),
new CaseSensitivePathsPlugin({
useBeforeEmitHook: useBeforeEmitHook,
}),
],
}, otherOpts);

Expand Down Expand Up @@ -56,6 +58,26 @@ describe('CaseSensitivePathsPlugin', () => {
done();
});
});

it('should handle errors correctly in emit hook mode', (done) => {
const compiler = webpackCompilerAtDir('wrong-case', {}, true);

compiler.run((err, stats) => {
if (err) done(err);
assert(stats.hasErrors());
assert.equal(stats.hasWarnings(), false);
const jsonStats = stats.toJson();
assert.equal(jsonStats.errors.length, 1);

const error = jsonStats.errors[0];
// check that the plugin produces the correct output
assert(error.indexOf('[CaseSensitivePathsPlugin]') > -1);
assert(error.indexOf('ExistingTestFile.js') > -1); // wrong file require
assert(error.indexOf('existingTestFile.js') > -1); // actual file name

done();
});
});
}

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

0 comments on commit e400f17

Please sign in to comment.