Skip to content

Commit 4371edc

Browse files
committed
Add error/warning location to compiled message
1 parent 32c9b9b commit 4371edc

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

index.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,31 @@ WebpackNotifierPlugin.prototype.compileMessage = function(stats) {
2727

2828
this.lastBuildSucceeded = false;
2929

30-
var message;
31-
if (error.module && error.module.rawRequest)
32-
message = error.module.rawRequest + '\n';
30+
var rawRequest, resource, line, column;
3331

34-
if (error.error)
35-
message = 'Error: ' + message + error.error.toString();
36-
else if (error.warning)
37-
message = 'Warning: ' + message + error.warning.toString();
32+
if (error.module) {
33+
rawRequest = error.module.rawRequest;
34+
resource = error.module.resource;
35+
}
36+
37+
var errorOrWarning = error.error || error.warning;
38+
if (errorOrWarning && errorOrWarning.loc) {
39+
line = errorOrWarning.loc.line;
40+
column = errorOrWarning.loc.column;
41+
}
42+
43+
var body = error.error ? 'Error: ' : error.warning ? 'Warning: ' : '' +
44+
rawRequest ? rawRequest + '\n' : '' +
45+
errorOrWarning ? errorOrWarning.toString() : '';
3846

39-
return message;
47+
return {
48+
body: body,
49+
location: {
50+
file: file,
51+
line: line,
52+
column: column
53+
}
54+
};
4055
};
4156

4257
WebpackNotifierPlugin.prototype.compilationDone = function(stats) {
@@ -47,7 +62,7 @@ WebpackNotifierPlugin.prototype.compilationDone = function(stats) {
4762

4863
notifier.notify({
4964
title: this.options.title || 'Webpack',
50-
message: msg,
65+
message: msg.body,
5166
contentImage: contentImage,
5267
icon: (os.platform() === 'win32') ? contentImage : undefined
5368
});

0 commit comments

Comments
 (0)