From b19f2cc3f98b685ae511889fc66ae53b8519af76 Mon Sep 17 00:00:00 2001 From: Anubhav Chaturvedi <3113465+anubhavchaturvedi@users.noreply.github.com> Date: Tue, 7 May 2024 12:16:23 -0700 Subject: [PATCH] Update ansi-color.js Fix for `Legacy octal escape is not permitted in strict mode` Reference : https://github.com/open-telemetry/opentelemetry-js/issues/3759#issuecomment-1674719937 --- lib/ansi-color.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ansi-color.js b/lib/ansi-color.js index 20fe35f..428d99c 100644 --- a/lib/ansi-color.js +++ b/lib/ansi-color.js @@ -27,14 +27,14 @@ var ANSI_CODES = { "white_bg": 47 }; -function setColor(str,color) { - if(!color) return str; +function setColor(str, color) { + if (!color) return str; var color_attrs = color.split("+"); var ansi_str = ""; - for(var i=0, attr; attr = color_attrs[i]; i++) { - ansi_str += "\033[" + ANSI_CODES[attr] + "m"; + for (var i = 0, attr; attr = color_attrs[i]; i++) { + ansi_str += "\x1b[" + ANSI_CODES[attr] + "m"; // \x1b is the hexadecimal representation for ESC (0o33 or \033 in octal) } - ansi_str += str + "\033[" + ANSI_CODES["off"] + "m"; + ansi_str += str + "\x1b[" + ANSI_CODES["off"] + "m"; return ansi_str; } @@ -59,4 +59,4 @@ if (typeof exports !== "undefined") { } else if (typeof define !== "undefined") { define([], function() { return { set: setColor, log: logMessage }; }); } -}()); \ No newline at end of file +}());