Skip to content

Commit 22081a9

Browse files
committed
Node 4 compat
1 parent a308bf7 commit 22081a9

File tree

10 files changed

+47
-27
lines changed

10 files changed

+47
-27
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
language: node_js
22
node_js:
3+
- 4
4+
- 5
35
- 6
46

57
cache:

src/core/extractWebpackError.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const RequestShortener = require("webpack/lib/RequestShortener");
24

35
// TODO: allow the location to be customized in options

src/core/formatErrors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
/**
24
* Applies formatters to all AnnotatedErrors.
35
*

src/core/transformErrors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const extractError = require('./extractWebpackError');
24

35
/**

src/debug.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const stripAnsi = require('strip-ansi');
24
const chalk = require('chalk');
35

@@ -24,26 +26,26 @@ class Debugger {
2426
this.capturedMessages = [];
2527
}
2628

27-
log (...args) {
29+
log () {
2830
if (this.enabled) {
29-
this.captureConsole(args, console.log);
31+
this.captureConsole(Array.from(arguments), console.log);
3032
}
3133
}
3234

33-
info (...args) {
35+
info () {
3436
if (this.enabled) {
35-
this.captureConsole(args, console.info, 'green');
37+
this.captureConsole(Array.from(arguments), console.info, 'green');
3638
}
3739
}
3840

39-
error (...args) {
41+
error () {
4042
// always show errors
41-
this.captureConsole(args, console.error, 'red');
43+
this.captureConsole(Array.from(arguments), console.error, 'red');
4244
}
4345

44-
warn (...args) {
46+
warn () {
4547
if (this.enabled) {
46-
this.captureConsole(args, console.warn, 'yellow');
48+
this.captureConsole(Array.from(arguments), console.warn, 'yellow');
4749
}
4850
}
4951

src/formatters/defaultError.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
'use strict';
2+
13
const chalk = require('chalk');
24

3-
function displayError(index, severity, { file, message, origin }) {
5+
function displayError(index, severity, error) {
46
const baseError = chalk.red(`${index + 1}) ${severity}`);
57

68
return [
7-
`${baseError} ${file ? 'in ' + file : ''}`,
9+
`${baseError} ${error.file ? 'in ' + error.file : ''}`,
810
'',
9-
message,
10-
(origin ? origin : undefined),
11+
error.message,
12+
(error.origin ? error.origin : undefined),
1113
''
1214
].filter(chunk => chunk !== undefined);
1315
}

src/formatters/moduleNotFound.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
function dependenciesNotFound(count) {
1+
'use strict';
2+
3+
function dependenciesNotFound (count) {
24
if (count === 1) {
35
return 'This dependency was not found in node_modules:';
46
}
57

68
return 'These dependencies were not found in node_modules:';
79
}
810

9-
function forgetToInstall(count) {
11+
function forgetToInstall (count) {
1012
if (count === 1) {
1113
return 'Did you forget to run npm install --save for it?';
1214
}
1315

1416
return 'Did you forget to run npm install --save for them?';
1517
}
1618

17-
function formatErrors(errors) {
19+
function formatErrors (errors) {
1820
if (errors.length === 0) {
1921
return [];
2022
}
2123

2224
return [
2325
dependenciesNotFound(errors.length),
24-
'',
25-
...errors.map(({ module }) =>`* ${module}`),
26-
'',
27-
forgetToInstall(errors.length),
28-
];
26+
''
27+
]
28+
.concat(errors.map(e =>`* ${e.module}`))
29+
.concat('', forgetToInstall(errors.length));
2930
}
3031

31-
function format(errors) {
32+
function format (errors) {
3233
return formatErrors(errors.filter((e) => (
3334
e.type === 'module-not-found'
3435
)));

src/friendly-errors-plugin.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const path = require('path');
24
const chalk = require('chalk');
35
const os = require('os');
@@ -25,10 +27,11 @@ const LOGO = path.join(__dirname, 'tarec_logo_ico.png');
2527

2628
class FriendlyErrorsWebpackPlugin {
2729

28-
constructor ({notificationTitle, compilationSuccessMessage, showNotifications} = {}) {
29-
this.notificationTitle = notificationTitle;
30-
this.compilationSuccessMessage = compilationSuccessMessage;
31-
this.notifier = showNotifications && safeRequire('node-notifier');
30+
constructor (options) {
31+
options = options || {};
32+
this.notificationTitle = options.notificationTitle;
33+
this.compilationSuccessMessage = options.compilationSuccessMessage;
34+
this.notifier = options.showNotifications && safeRequire('node-notifier');
3235
}
3336

3437
notify (serverity, error) {

src/transformers/babelSyntax.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
function cleanStackTrace(message) {
24
return message
35
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, ''); // at ... ...:x:y

src/transformers/moduleNotFound.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
'use strict';
2+
13
const TYPE = 'module-not-found';
24

3-
function isModuleNotFoundError(e) {
4-
const { webpackError = {} } = e;
5+
function isModuleNotFoundError (e) {
6+
const webpackError = e.webpackError || {};
57
return webpackError.dependencies && webpackError.dependencies.length &&
68
(e.type === TYPE ||
79
e.name === 'ModuleNotFoundError' &&

0 commit comments

Comments
 (0)