1 |
|
2 |
|
3 | const { Writable } = require('stream')
|
4 |
|
5 | function polyfill () {
|
6 | if (!process.stdout) {
|
7 | process.stdout = new Writable({
|
8 | write (chunks, encoding, cb) {
|
9 | console.log(chunks.toString('utf-8'))
|
10 | process.nextTick(cb)
|
11 | }
|
12 | })
|
13 | }
|
14 |
|
15 | if (!process.stderr) {
|
16 | process.stderr = new Writable({
|
17 | write (chunks, encoding, cb) {
|
18 | console.error(chunks.toString('utf-8'))
|
19 | process.nextTick(cb)
|
20 | }
|
21 | })
|
22 | }
|
23 | }
|
24 |
|
25 | module.exports = polyfill
|