From e0e713d975beac9bb528d39698f67481dc0ffe36 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sun, 12 Apr 2026 18:10:06 +0900 Subject: [PATCH] Add muted mode and restructure console echo Introduce a _muted() helper to check for a WScript "quiet" argument and avoid output when muted. Replace the old _echoDefault with a unified _echoCallback(params, type) that writes messages via WScript and respects the muted flag. Refactor _echo to build a params object (including params.message and scope), prepend the optional type, invoke _echoCallback, and push the composed message to _messages. Adjust callback invocation logic (remove the previous null check and inline handling). --- app.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 9e705de..0ecf4f6 100644 --- a/app.js +++ b/app.js @@ -36,12 +36,21 @@ var console = { } return res; }, - _echoDefault: function(message) { + _muted: function() { + try { + if (typeof WScript !== "undefined") + return WScript.Arguments.Named.Exists("quiet"); + } catch (e) { /* ignore */ } + + return false; + }, + _echoCallback: function(params, type) { + if (this._muted()) return; + if (typeof WScript !== "undefined") { - WScript.StdOut.WriteLine("[*] " + message); + WScript.StdOut.WriteLine("[*] " + params.message); } }, - _echoCallback: null, _echo: function(args, type) { var messages = []; var params = { @@ -80,19 +89,15 @@ var console = { } } - var message = messages.join(' '); + params.message = messages.join(' '); if (typeof type !== "undefined") { - message = type + ": " + message; + params.message = type + ": " + params.message; } - this._echoDefault(message); - this._messages.push(message); - - if (params.scope.length > 0 && this._echoCallback != null) { - try { - this._echoCallback(params, type); - } catch (e) { - this._echoDefault("Exception:" + e.message); - } + this._echoCallback(params); + this._messages.push(params.message); + + if (params.scope.length > 0) { + this._echoCallback(params, type); } }, assert: function(assertion) {