-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
63 lines (52 loc) · 1.24 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict'
const anybar = require('anybar')
const captureExit = require('capture-exit')
const exec = require('child_process').exec
const isOSX = require('os').platform() === 'darwin'
// Pulse
let color = 'black'
let pulser
function pulse () {
clearInterval(pulser)
pulser = setInterval(() => {
anybar(color)
color = color === 'black' ? 'white' : 'black'
}, 200)
};
if (!isOSX) {
/* AnyBar is an OSX-only application. */
module.exports = {
name: 'ember-cli-anybar',
}
} else {
// Open AnyBar
exec('open --hide --background -a AnyBar', (error, stdout, stderror) => {
if (error) {
console.error(`
You have the ember-cli-anybar addon installed but have
not yet installed the AnyBar application. Please run:
brew cask install anybar
`)
}
})
// Back to white on exit
captureExit.captureExit()
captureExit.onExit(function resetAnyBar () {
clearInterval(pulser)
return anybar('white')
})
module.exports = {
name: 'ember-cli-anybar',
preBuild () {
pulse()
},
buildError: function buildError () {
clearInterval(pulser)
anybar('red')
},
postBuild: function postBuild () {
clearInterval(pulser)
anybar('green')
},
}
}