-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (35 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const notifier = require('node-notifier');
const path = require('path');
const DEFAULT_ICON_PATH = path.resolve(__dirname, 'icons');
const successIcon = path.join(DEFAULT_ICON_PATH, 'success.png');
const errorIcon = path.join(DEFAULT_ICON_PATH, 'failed.png');
module.exports = options => {
return {
name: 'esbuild-build-notifier',
setup(build) {
build.onEnd((res) => {
if (res.errors.length > 0) {
res.errors.forEach((e) => {
const location = e.location;
const title = e.text;
const message = `${location.file},(${location.line}:${location.column})\n${location.lineText}`;
notifier.notify({
title,
sound: 'Submarine',
message,
icon: errorIcon,
});
});
} else {
notifier.notify({
'app-name': 'my app',
title: "🚀 Success!",
message: "Compiled Successfully!!",
icon: successIcon,
sound: 'Funk'
});
}
});
}
}
}