1 parent e2a9e49 commit 4429329Copy full SHA for 4429329
1 file changed
src/components/utils/log.ts
@@ -1,5 +1,22 @@
1
import log from "npmlog";
2
-import fs from "fs";
3
-import path from "path";
+
+if (process.env.DEBUG === "false") {
4
+ const methodsToPatch = ["error", "warn"];
5
6
+ for (const method of methodsToPatch) {
7
+ const original = log[method].bind(log);
8
9
+ log[method] = function (prefix: string, ...args: any[]) {
10
+ const formattedArgs = args.map((arg) => {
11
+ if (arg instanceof Error) {
12
+ return `${arg.name}: ${arg.message}`;
13
+ }
14
+ return arg;
15
+ });
16
17
+ return original(prefix, ...formattedArgs);
18
+ };
19
20
+}
21
22
export default log;
0 commit comments