Skip to content

Commit

Permalink
perf: small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 28, 2023
1 parent 5035663 commit 6aef144
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/vitest/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ const ERASE_DOWN = `${ESC}J`
const ERASE_SCROLLBACK = `${ESC}3J`
const CURSOR_TO_START = `${ESC}1;1H`
const CLEAR_SCREEN = '\x1Bc'
const HIGHLIGHT_SUPPORTED_LANGS = ['js', 'ts']
const HIGHLIGHT_SUPPORTED_EXTS = HIGHLIGHT_SUPPORTED_LANGS.flatMap(lang => [
const HIGHLIGHT_SUPPORTED_EXTS = new Set(['js', 'ts'].flatMap(lang => [
`.${lang}`,
`.m${lang}`,
`.c${lang}`,
`.${lang}x`,
`.m${lang}x`,
`.c${lang}x`,
])
]))

export class Logger {
outputStream = process.stdout
Expand Down Expand Up @@ -114,7 +113,7 @@ export class Logger {
if (this._highlights.has(filename))
return this._highlights.get(filename)!
const ext = extname(filename)
if (!HIGHLIGHT_SUPPORTED_EXTS.includes(ext))
if (!HIGHLIGHT_SUPPORTED_EXTS.has(ext))
return source
const isJsx = ext.endsWith('x')
const code = highlight(source, { jsx: isJsx, colors: c })
Expand Down

0 comments on commit 6aef144

Please sign in to comment.