-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnotification.js
116 lines (93 loc) · 2.5 KB
/
notification.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const sample = require('./util/sample')
const linter = require('./behaviors/linter')
const cursor = require('./behaviors/cursor')
const active = require('./behaviors/active')
const startingBoredThreshold = 2*60*1000 // 2 minutes
let projectPath = null
let path = null
let lastNotification = new Date()
let boredThreshold = startingBoredThreshold
module.exports = (notification) => {
let now = new Date()
if (notification.type === 'tick') {
if (now - lastNotification > boredThreshold) {
boredThreshold = boredThreshold*2
console.log(`Next bored action in ${boredThreshold/1000}s`)
global.furbies.sampleEmotion('sleepy')
}
if (projectPath) {
global.furbies.ciStatus(projectPath)
}
} else {
console.log('*************************************')
console.log(notification)
lastNotification = now
boredThreshold = startingBoredThreshold
}
if (notification.projectPath) {
projectPath = notification.projectPath
}
if (notification.type === 'active') {
path = notification.path
active.update(notification.path)
}
if (notification.type === 'change') {
path = notification.path
if (notification.lineText.match(/^\s*(var|let|const)\s+$/)) {
global.furbies.sampleAction([
"oooh, pick a good one!",
"let's name baby",
"ooh, name for kah? (sing) Oooh"
])
}
if (notification.lineText.match(/(^\s*function|\(\))$/)) {
global.furbies.sampleEmotion(['collab', 'smalltalk'])
}
if (notification.change.match(/^\s*s+\s*/)) {
global.furbies.sampleAction([
"mmm… s s s s"
])
}
}
if (notification.type === 'cursor') {
cursor.update(notification.path, notification.old, notification.new)
}
if (notification.type === 'open') {
global.furbies.sampleEmotion('beginning')
}
if (notification.type === 'destroy') {
global.furbies.cycleEmotion('goodbye')
}
if (notification.type === 'linter') {
linter.update(path, notification.count)
}
}
/*
- Test failed
- Test passed
- Started variable
- Started function
- Finished function
- In complex function
- In a method that doesn't have test coverage
- Added a linter error
- Fixed a linter error
- In duplicated code
- CI build status
- Naming conventions (NLP)
- JSHint (if Javascript)
*/
/*
Sitting down
Small talk to get started
Starting a variable
Starting a function name
Things broken
Distracted, sleep, bored
Let's do this
Things fixed
Praise
Resolution
Commit
Build passes
*/