Skip to content

Commit bd02737

Browse files
committed
Add onclick listener on notifier that runs editor
1 parent 4371edc commit bd02737

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
var path = require('path');
22
var os = require('os');
3+
var exec = require('child_process').exec;
34
var notifier = require('node-notifier');
45

56
var DEFAULT_LOGO = path.join(__dirname, 'logo.png');
67

78
var WebpackNotifierPlugin = module.exports = function(options) {
89
this.options = options || {};
910
this.lastBuildSucceeded = false;
11+
12+
if (this.options.editor) {
13+
notifier.on('click', function(notifierObject, notifierOptions) {
14+
var file = notifierOptions.location.file;
15+
if (file) {
16+
exec(options.editor, [file]);
17+
}
18+
});
19+
}
1020
};
1121

1222
WebpackNotifierPlugin.prototype.compileMessage = function(stats) {
@@ -64,7 +74,9 @@ WebpackNotifierPlugin.prototype.compilationDone = function(stats) {
6474
title: this.options.title || 'Webpack',
6575
message: msg.body,
6676
contentImage: contentImage,
67-
icon: (os.platform() === 'win32') ? contentImage : undefined
77+
icon: (os.platform() === 'win32') ? contentImage : undefined,
78+
wait: !!this.options.editor,
79+
location: msg.location
6880
});
6981
}
7082
};

0 commit comments

Comments
 (0)