-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (26 loc) · 900 Bytes
/
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 showOnlyErrors = (process.env.PARCEL_NOTIFIER_LEVEL === 'error');
let lastBuildHadError = false;
module.exports = function (bundler) {
if ( ! showOnlyErrors ) {
bundler.on('buildEnd', () => {
// lastBuildHadError is used as a flag to now show the "Build finished" message if there was a build error
if (lastBuildHadError) {
lastBuildHadError = false; // clear the "error" flag
}
else {
notifier.notify({
title: 'Build finished.',
message: 'parcel-bundler',
});
}
});
}
bundler.on('buildError', error => {
notifier.notify({
title: 'Build FAILED!',
message: 'parcel-bundler',
});
lastBuildHadError = true;
});
};