From 38196f7850d7498e98f5ec7c66801deadabe09cf Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Fri, 18 Sep 2020 21:28:30 +0800 Subject: fix(cli/console): always quote and escape inspected strings (#7546) --- cli/rt/02_console.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'cli/rt') diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js index 34e106ff2..f82262a7e 100644 --- a/cli/rt/02_console.js +++ b/cli/rt/02_console.js @@ -405,7 +405,7 @@ switch (typeof value) { case "string": - return value; + return green(quoteString(value)); case "number": // Numbers are yellow // Special handling of -0 return yellow(Object.is(value, -0) ? "-0" : `${value}`); @@ -1265,8 +1265,12 @@ if (a > 0) { string += " "; } - // Use default maximum depth for null or undefined arguments. - string += inspectValue(args[a], new Set(), 0, rInspectOptions); + if (typeof args[a] == "string") { + string += args[a]; + } else { + // Use default maximum depth for null or undefined arguments. + string += inspectValue(args[a], new Set(), 0, rInspectOptions); + } } if (rInspectOptions.indentLevel > 0) { @@ -1543,16 +1547,12 @@ value, inspectOptions = {}, ) { - if (typeof value === "string") { - return value; - } else { - return inspectValue(value, new Set(), 0, { - ...DEFAULT_INSPECT_OPTIONS, - ...inspectOptions, - // TODO(nayeemrmn): Indent level is not supported. - indentLevel: 0, - }); - } + return inspectValue(value, new Set(), 0, { + ...DEFAULT_INSPECT_OPTIONS, + ...inspectOptions, + // TODO(nayeemrmn): Indent level is not supported. + indentLevel: 0, + }); } // Expose these fields to internalObject for tests. -- cgit v1.2.3