Skip to content

Commit 5888b06

Browse files
fix(router-generator): do not log emojis when process.env.CI is set (#2492)
1 parent 7ff3787 commit 5888b06

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

packages/router-generator/src/utils.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,37 @@ export function trimPathLeft(path: string) {
4141
}
4242

4343
export function logging(config: { disabled: boolean }) {
44+
function stripEmojis(str: string) {
45+
return str.replace(
46+
/[\p{Emoji_Presentation}\p{Extended_Pictographic}]/gu,
47+
'',
48+
)
49+
}
50+
51+
function formatLogArgs(args: Array<any>): Array<any> {
52+
if (process.env.CI) {
53+
return args.map((arg) =>
54+
typeof arg === 'string' ? stripEmojis(arg) : arg,
55+
)
56+
}
57+
return args
58+
}
59+
4460
return {
4561
log: (...args: Array<any>) => {
46-
if (!config.disabled) console['log'](...args)
62+
if (!config.disabled) console.log(...formatLogArgs(args))
4763
},
4864
debug: (...args: Array<any>) => {
49-
if (!config.disabled) console.debug(...args)
65+
if (!config.disabled) console.debug(...formatLogArgs(args))
5066
},
5167
info: (...args: Array<any>) => {
52-
if (!config.disabled) console.info(...args)
68+
if (!config.disabled) console.info(...formatLogArgs(args))
5369
},
5470
warn: (...args: Array<any>) => {
55-
if (!config.disabled) console.warn(...args)
71+
if (!config.disabled) console.warn(...formatLogArgs(args))
5672
},
5773
error: (...args: Array<any>) => {
58-
if (!config.disabled) console.error(...args)
74+
if (!config.disabled) console.error(...formatLogArgs(args))
5975
},
6076
}
6177
}

0 commit comments

Comments
 (0)