-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.js
70 lines (53 loc) · 2.1 KB
/
dev.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
const net = require('net');
const path = require('path');
const fs = require('fs');
const pathToTheSocket = path.join(process.cwd(), 'dev.socket');
try {
fs.unlinkSync(pathToTheSocket);
} catch (error) {}
const server = net.createServer().listen(pathToTheSocket, () => {
console.info('Test server has _started, use inspector to test it.');
const bstc = require('./bind-std-to-console');
if (process.env.NODE_ENV !== 'production') {
bstc.start();
}
setTimeout(() => {
console.log('Console.log: foo');
console.log('Console.log: bar');
console.log('Console.log: zaz');
console.error('Console.error: foo');
console.error('Console.error: bar');
console.error('Console.error: zaz');
process.stdout.write('Stdout: foo\n');
process.stdout.write('Stdout: bar\n');
process.stdout.write('Stdout: zaz\n');
process.stderr.write('Stderr: foo\n');
process.stderr.write('Stderr: bar\n');
process.stderr.write('Stderr: zaz\n');
process.stdout.write(`
[32minfo[39m: Colored message
{ key: [32m'like a json'[39m,
number: [33m0.02632[39m,
child: { message: [32m'This is so colorized!!!'[39m } }\n`);
// Changing the level to debug and warn:
bstc.stdoutToConsole = console.debug;
bstc.stderrToConsole = console.warn;
console.debug('Console.debug: foo');
console.debug('Console.debug: bar');
console.debug('Console.debug: zaz');
console.warn('Console.warn: foo');
console.warn('Console.warn: bar');
console.warn('Console.warn: zaz');
process.stdout.write('Stdout: foo\n');
process.stdout.write('Stdout: bar\n');
process.stdout.write('Stdout: zaz\n');
process.stderr.write('Stderr: foo\n');
process.stderr.write('Stderr: bar\n');
process.stderr.write('Stderr: zaz\n');
process.stdout.write(`
[32minfo[39m: Colored message
{ key: [32m'like a json'[39m,
number: [33m0.02632[39m,
child: { message: [32m'This is so colorized!!!'[39m } }\n`);
}, 3e3);
});