-
Notifications
You must be signed in to change notification settings - Fork 1
/
console.js
59 lines (49 loc) · 1.16 KB
/
console.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
/**
* Dependencies
*/
const path = require('path');
const package = require(path.join(__dirname, '../../', 'package.json'));
const args = require(`${__dirname}/args`).args;
const resolve = require(`${__dirname}/resolve`);
const alerts = resolve('config/alerts');
const PWD = '.';
const PKG = '@pttrn';
/**
*
*/
const replace = (str) => {
let pwd = new RegExp(process.env.PWD, 'g');
let file = new RegExp('file://', 'g');
let pkg = new RegExp(`./node_modules/${package.name}`, 'g');
return str
.replace(file, '')
.replace(pwd, PWD)
.replace(pkg, PKG);
};
const always = (message) => {
console.log(replace(message));
};
const notify = (message) => {
if (args.notify)
console.log(replace(message));
};
const describe = (message) => {
if (args.notify && args.nondescript === false)
console.log(replace(message));
};
module.exports = {
describe: describe,
notify: notify,
lint: message => {
always(message);
},
watching: message => {
notify(`${alerts.watching} ${message}`);
},
success: message => {
notify(`${alerts.success} ${message}`);
},
error: message => {
always(`${alerts.error} ${message}`);
}
};