From 063ef6852f1f25c6108b0b17c3f60a1495b71bec Mon Sep 17 00:00:00 2001 From: drdevlin Date: Fri, 5 Mar 2021 17:11:37 -0500 Subject: [PATCH 1/3] Fix #3591: refactor debugInfo from class to function --- packages/less/src/less/tree/debug-info.js | 60 +++++++++++------------ 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/packages/less/src/less/tree/debug-info.js b/packages/less/src/less/tree/debug-info.js index e23472190..ca0a29097 100644 --- a/packages/less/src/less/tree/debug-info.js +++ b/packages/less/src/less/tree/debug-info.js @@ -1,38 +1,36 @@ -class debugInfo { - constructor(context, ctx, lineSeparator) { - let result = ''; - if (context.dumpLineNumbers && !context.compress) { - switch (context.dumpLineNumbers) { - case 'comments': - result = debugInfo.asComment(ctx); - break; - case 'mediaquery': - result = debugInfo.asMediaQuery(ctx); - break; - case 'all': - result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx); - break; - } - } - return result; - } +function asComment(ctx) { + return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`; +} - static asComment(ctx) { - return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`; +function asMediaQuery(ctx) { + let filenameWithProtocol = ctx.debugInfo.fileName; + if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { + filenameWithProtocol = `file://${filenameWithProtocol}`; } + return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { + if (a == '\\') { + a = '\/'; + } + return `\\${a}`; + })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`; +} - static asMediaQuery(ctx) { - let filenameWithProtocol = ctx.debugInfo.fileName; - if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { - filenameWithProtocol = `file://${filenameWithProtocol}`; +function debugInfo(context, ctx, lineSeparator) { + let result = ''; + if (context.dumpLineNumbers && !context.compress) { + switch (context.dumpLineNumbers) { + case 'comments': + result = asComment(ctx); + break; + case 'mediaquery': + result = asMediaQuery(ctx); + break; + case 'all': + result = asComment(ctx) + (lineSeparator || '') + asMediaQuery(ctx); + break; } - return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { - if (a == '\\') { - a = '\/'; - } - return `\\${a}`; - })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`; } + return result; } -export default debugInfo; +export default debugInfo; \ No newline at end of file From 5a8118d42f147fab3c4aa1dcc1ab7c9615cd111e Mon Sep 17 00:00:00 2001 From: Lei Chen Date: Mon, 29 Nov 2021 11:20:19 +0800 Subject: [PATCH 2/3] chore: add newline --- packages/less/src/less/tree/debug-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/less/src/less/tree/debug-info.js b/packages/less/src/less/tree/debug-info.js index ca0a29097..4281bfda4 100644 --- a/packages/less/src/less/tree/debug-info.js +++ b/packages/less/src/less/tree/debug-info.js @@ -33,4 +33,4 @@ function debugInfo(context, ctx, lineSeparator) { return result; } -export default debugInfo; \ No newline at end of file +export default debugInfo; From 26d831786ac3e1a54949eac6f5aa6f465632ee89 Mon Sep 17 00:00:00 2001 From: Lei Chen Date: Thu, 30 Dec 2021 22:08:05 +0800 Subject: [PATCH 3/3] chore: trigger ci --- packages/less/src/less/tree/debug-info.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/less/src/less/tree/debug-info.js b/packages/less/src/less/tree/debug-info.js index 4281bfda4..804e71723 100644 --- a/packages/less/src/less/tree/debug-info.js +++ b/packages/less/src/less/tree/debug-info.js @@ -34,3 +34,4 @@ function debugInfo(context, ctx, lineSeparator) { } export default debugInfo; +