Don't use through2 in prettyPrint
This commit is contained in:
parent
1b736b1446
commit
f1a9d11dcf
@ -1,7 +1,7 @@
|
|||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import * as pump from "pump";
|
import * as pump from "pump";
|
||||||
import * as split from "split2";
|
import * as split from "split2";
|
||||||
import * as through from "through2";
|
import { Transform, TransformCallback } from "stream";
|
||||||
|
|
||||||
type Level = "default" | 60 | 50 | 40 | 30 | 20 | 10;
|
type Level = "default" | 60 | 50 | 40 | 30 | 20 | 10;
|
||||||
|
|
||||||
@ -121,20 +121,22 @@ function asColoredLevel(value: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const prettyTransport = through.obj((chunk, enc, cb) => {
|
class PrettyPrintTranform extends Transform {
|
||||||
let value: any;
|
_transform(chunk: any, encoding: string, cb: TransformCallback) {
|
||||||
try {
|
let value: any;
|
||||||
value = JSON.parse(chunk.toString());
|
try {
|
||||||
} catch (e) {
|
value = JSON.parse(chunk.toString());
|
||||||
process.stdout.write(chunk.toString() + "\n");
|
} catch (e) {
|
||||||
return cb();
|
process.stdout.write(chunk.toString() + "\n");
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
const line = formatter(value);
|
||||||
|
if (!line) {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
process.stdout.write(line);
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
const line = formatter(value);
|
}
|
||||||
if (!line) {
|
|
||||||
return cb();
|
|
||||||
}
|
|
||||||
process.stdout.write(line);
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
|
|
||||||
pump(process.stdin, split(), prettyTransport);
|
pump(process.stdin, split(), new PrettyPrintTranform());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user