forked from adamlaska/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
34 lines (29 loc) · 671 Bytes
/
utils.js
File metadata and controls
34 lines (29 loc) · 671 Bytes
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
const chalk = require('chalk');
class Logger {
/** @param {string} title */
constructor(title) {
this.title = title;
this.errors = [];
}
/** @param {...unknown} message */
error(...message) {
this.errors.push(message.join(' '));
}
emit() {
const errorCount = this.errors.length;
if (errorCount) {
console.error(
chalk`{red ${this.title} – {bold ${errorCount}} ${
errorCount === 1 ? 'error' : 'errors'
}:}`,
);
for (const error of this.errors) {
console.error(` ${error}`);
}
}
}
hasErrors() {
return !!this.errors.length;
}
}
module.exports = { Logger };