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 c69f7d0 commit c3eacdb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/babel-plugin-enhance-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ export interface Options {
const DEFAULT_PRE_TIP = '🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀'
const SKIP_KEY = '@@babel-plugin-enhance-logSkip'

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 @@ -129,13 +129,13 @@ export default declare<Options>((babel, { preTip = DEFAULT_PRE_TIP, splitBy = ''
if (loc) {
const startLine = loc.start.line

const startLineTipNode = t.stringLiteral(`${generateLineOfTip(relativeFilename, startLine)}${handleStartFileNameTip(relativeFilename, startLine)}\n`)
const startLineTipNode = t.stringLiteral(`${generateLineOfTip(relativeFilename, startLine)}${handleFileNameTip(relativeFilename, startLine)}\n`)
nodeArguments.unshift(startLineTipNode)
if (enableEndLine) {
const endLine = loc.end.line
if (endLine === startLine)
return
const endLineTipNode = t.stringLiteral(`\n${generateLineOfTip(relativeFilename, endLine)}${handleEndFileNameTip(relativeFilename, endLine)}`)
const endLineTipNode = t.stringLiteral(`\n${generateLineOfTip(relativeFilename, endLine)}${handleFileNameTip(relativeFilename, endLine)}`)
nodeArguments.push(endLineTipNode)
}
}
Expand Down

0 comments on commit c3eacdb

Please sign in to comment.