Skip to content

Commit

Permalink
fix: remove filename color tip
Browse files Browse the repository at this point in the history
  • Loading branch information
baozouai committed Aug 3, 2023
1 parent 929cbc6 commit a98b26e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/index.ts
Expand Up @@ -53,17 +53,17 @@ export interface Options {
endLine?: boolean
}

const colorGreen = '\x1B[32m'
const colorBlue = '\x1B[34m'
const colorReset = '\x1B[0m'
// const colorGreen = '\x1B[32m'
// const colorBlue = '\x1B[34m'
// const colorReset = '\x1B[0m'

function handleStartFileNameTip(filePath: string, lineNumber: number) {
if (!filePath)
return ''
return ` ~ ${colorGreen}${filePath}:${colorBlue}${lineNumber}${colorReset}`
}
// function handleStartFileNameTip(filePath: string, lineNumber: number) {
// if (!filePath)
// return ''
// return ` ~ ${colorGreen}${filePath}:${colorBlue}${lineNumber}${colorReset}`
// }

function handleEndFileNameTip(filePath: string, lineNumber: number) {
function handleFileNameTip(filePath: string, lineNumber: number) {
if (!filePath)
return ''
return ` ~ ${filePath}:${lineNumber}`
Expand Down Expand Up @@ -160,7 +160,7 @@ export default function enhanceLogPlugin(options: Options = {}): PluginOption {
if (typeof enableFileName === 'object' && !enableFileName.enableDir)
relativeFilename = relativeFilename.replace(/.*\//, '')
}
const startLineTipNode = stringLiteral(`${generateLineOfTip(relativeFilename, startLine!)}${handleStartFileNameTip(relativeFilename, startLine!)}\n`)
const startLineTipNode = stringLiteral(`${generateLineOfTip(relativeFilename, startLine!)}${handleFileNameTip(relativeFilename, startLine!)}\n`)
nodeArguments.unshift(startLineTipNode)
if (enableEndLine) {
const { line, column } = loc.end
Expand All @@ -171,7 +171,7 @@ export default function enhanceLogPlugin(options: Options = {}): PluginOption {
// if startLine === endLine, needn't log endLine
if (startLine === endLine)
return
const endLineTipNode = stringLiteral(`\n${generateLineOfTip(relativeFilename, endLine!)}${handleEndFileNameTip(relativeFilename, endLine!)}\n`)
const endLineTipNode = stringLiteral(`\n${generateLineOfTip(relativeFilename, endLine!)}${handleFileNameTip(relativeFilename, endLine!)}\n`)
nodeArguments.push(endLineTipNode)
}
}
Expand Down

0 comments on commit a98b26e

Please sign in to comment.