-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulp.messages.js
78 lines (74 loc) · 2.2 KB
/
gulp.messages.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
const chalk = require('chalk');
const path = require('path');
class Time {
constructor() {
this.date = Date.now();
}
static getTime() {
let time = new Date();
let seconds = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds();
let minutes = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes();
return `[${time.getHours()}:${minutes}:${seconds}]`;
}
start() {
this.date = Date.now();
return this.date;
}
end() {
let result = Number(Date.now()) - Number(this.date);
return result;
}
}
module.exports = {
build: {
start: () => {
console.log('');
console.log(chalk.bgBlue(' ======================= '));
console.log(chalk.bgBlue(' <<<< BUILD STARTED >>>> '));
console.log(chalk.bgBlue(' ======================= '));
console.log('');
},
end: () => {
console.log('');
console.log(chalk.bgBlue(' ======================== '));
console.log(chalk.bgBlue(' <<<< BUILD COMPLETE >>>> '));
console.log(chalk.bgBlue(' ======================== '));
console.log('');
}
},
error: {
start: (errName) => {
console.log('');
let errEqNeeded = ' ================';
for (let i = 0, l = errName.length; i < l; i++) {
errEqNeeded += '=';
}
console.log(chalk.bgRed(errEqNeeded + ' '));
console.log(chalk.bgRed(` <<<< ERROR ${errName} >>>> `));
console.log(chalk.bgRed(errEqNeeded + ' '));
console.log('');
},
end: () => {
console.log('');
console.log(chalk.bgRed(' =================== '));
console.log(chalk.bgRed(` <<<< ERROR END >>>> `));
console.log(chalk.bgRed(' =================== '));
console.log('');
}
},
success: (message, time) => {
console.log(chalk.cyan(Time.getTime()) + ' ' + chalk.green(message) + ' in ' + chalk.magenta(time) + 'ms');
},
watch: {
init: () => {
console.log('');
console.log(chalk.bgBlue(' ============================== '));
console.log(chalk.bgBlue(' <<<< WATCHING FOR CHANGES >>>> '));
console.log(chalk.bgBlue(' ============================== '));
console.log('');
},
change: (event, message) => {
console.log(chalk.cyan(Time.getTime()) + ' ' + chalk.bgMagenta(' ' + event.type + ' ') + ' ' + path.basename(event.path) + ' ' + chalk.green(message));
}
}
}