From f61d13ca910a4fc894540e35d6edabf37811c1e9 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Mon, 31 Jul 2023 00:53:30 +1000 Subject: [PATCH] fix(cli): make args["--json"] state available to print funcs --- bin.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin.mjs b/bin.mjs index 6c06763..8d0f9a8 100755 --- a/bin.mjs +++ b/bin.mjs @@ -124,10 +124,11 @@ const compileOptsToArgSpec = (options) => { }); }; +let __json; const printHelp = (commands, options) => { const { name, version, homepage } = manifest, usage = `${name} [options]`; - if (args["--json"]) { + if (__json) { printObject({ name, version, @@ -150,7 +151,7 @@ const printHelp = (commands, options) => { } }, printVersion = () => { - if (args["--json"]) { + if (__json) { printObject({ [manifest.name]: manifest.version, node: process.version.slice(1), @@ -208,6 +209,7 @@ try { const args = arg(compileOptsToArgSpec(options)); if (args["--debug"]) __debug = true; if (args["--quiet"]) __quiet = true; + if (args["--json"]) __json = true; if (args["--no"] || args["--quiet"]) __confirmation = "n"; if (args["--yes"]) __confirmation = "y"; if (args["--help"]) printHelp(commands, options), process.exit(); @@ -340,7 +342,7 @@ try { break; } case "check": { - if (args["--json"]) { + if (__json) { printObject({ appPath, backupPath,