diff --git a/src/core/transform/common.ts b/src/core/transform/common.ts index 0b36e9e..fa8b7b3 100644 --- a/src/core/transform/common.ts +++ b/src/core/transform/common.ts @@ -21,7 +21,7 @@ export function genConsoleString(genContext: GenContext) { argsName = `${argsName.slice(0, 30)}...` // not output when argtype is string or number - const lineInfo = `${_prefix}%c🚀 ${fileName}:${originalLine}${['StringLiteral', 'NumericLiteral'].includes(argType) ? '' : ` ~ ${argsName}`}` + const lineInfo = `%c🚀 ${fileName}:${originalLine}${['StringLiteral', 'NumericLiteral'].includes(argType) ? '' : ` ~ ${argsName}`}` const codePosition = `${relative(cwd(), filePath)}:${originalLine}:${(originalColumn || 0) + 1}` const launchEditorString = `%c🔦 http://localhost:${port}/client#${Buffer.from(codePosition, 'utf-8').toString('base64')}` @@ -29,13 +29,16 @@ export function genConsoleString(genContext: GenContext) { let consoleString = '' if (!disableHighlight && !disableHighlight) - consoleString = `"${lineInfo}${launchEditorString}","${getConsoleStyle(fileType)}","${launchEditorStyle}","\\n",` + consoleString = `"${_prefix}${lineInfo}${launchEditorString}","${getConsoleStyle(fileType)}","${launchEditorStyle}","\\n",` if (disableHighlight && !disableLaunchEditor) - consoleString = `"${launchEditorString}","${launchEditorStyle}","\\n",` + consoleString = `"${_prefix}${launchEditorString}","${launchEditorStyle}","\\n",` if (!disableHighlight && disableLaunchEditor) - consoleString = `"${lineInfo}","${getConsoleStyle(fileType)}","\\n",` + consoleString = `"${_prefix}${lineInfo}","${getConsoleStyle(fileType)}","\\n",` + + if (disableHighlight && disableLaunchEditor) + consoleString = `"${_prefix}",` return { consoleString, diff --git a/test/__snapshots__/options.test.ts.snap b/test/__snapshots__/options.test.ts.snap index f47c129..dcca15c 100644 --- a/test/__snapshots__/options.test.ts.snap +++ b/test/__snapshots__/options.test.ts.snap @@ -2,10 +2,10 @@ exports[`options > disable all 1`] = ` { - "code": "console.log('hello javascript',\\"\\")", + "code": "console.log(\\"\\",'hello javascript',\\"\\")", "map": SourceMap { "file": undefined, - "mappings": "AAAA,YAAY,qBAAkB", + "mappings": "AAAA,eAAY,qBAAkB", "names": [], "sources": [ "/home/runner/work/unplugin-turbo-console/src/App.vue", @@ -66,10 +66,10 @@ exports[`options > empty option 1`] = ` exports[`options > perfix suffix 1`] = ` { - "code": "console.log(\\"xxxx \\\\n%c🚀 App.vue:1%c🔦 http://localhost:undefined/client#Li4vLi4vaG9tZS9ydW5uZXIvd29yay91bnBsdWdpbi10dXJiby1jb25zb2xlL3NyYy9BcHAudnVlOjE6MQ==\\",\\"padding:2px 5px; border-radius:3px 0 0 3px;color: #fff; background: #4FC08D\\",\\"background: #00DC8250;padding:2px 5px;border-radius:0 3px 3px 0;margin-bottom:5px\\",\\"\\\\n\\",'hello javascript',\\"\\\\n yyy\\")", + "code": "console.log(\\"xxxx \\\\n\\",'hello javascript',\\"\\\\n yyy\\")", "map": SourceMap { "file": undefined, - "mappings": "AAAA,sUAAY,2BAAkB", + "mappings": "AAAA,sBAAY,2BAAkB", "names": [], "sources": [ "/home/runner/work/unplugin-turbo-console/src/App.vue", diff --git a/test/fixtures/option.ts b/test/fixtures/option.ts index 95db62e..633300d 100644 --- a/test/fixtures/option.ts +++ b/test/fixtures/option.ts @@ -2,7 +2,8 @@ export const optionWithPrefix = { options: { prefix: 'xxxx', suffix: 'yyy', - disableLaunchEditor: false, + disableLaunchEditor: true, + disableHighlight: true, }, code: `console.log('hello javascript')`, id: '/home/runner/work/unplugin-turbo-console/src/App.vue',