From 2a862bb2bd832e3ebddc5ed76096c434a51f01ba Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 1 Apr 2026 10:16:20 +0800 Subject: [PATCH] fix: auto-patch Commander.js multi-char short flags in postinstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The source uses -d2e flag which Commander.js rejects (single-char only). postinstall.sh now patches both: 1. shortFlagExp regex: /^-[^-]$/ → /^-[^-]+$/ 2. single-char restriction check disabled Users no longer need to manually patch node_modules after bun install. --- scripts/postinstall.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index 5505886..505ddeb 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -117,3 +117,13 @@ STUBEOF fi echo "[postinstall] Stubs created." + +# ── Patch Commander.js for multi-char short flags ─────────────────────────── +OPTION_JS=$(find node_modules -path "*/commander/lib/option.js" -type f | head -1) +if [ -n "$OPTION_JS" ]; then + # Patch 1: shortFlagExp — allow one or more chars after dash + sed -i "s|shortFlagExp = /\^-\\[^-\\]\\$/|shortFlagExp = /\^-[^-]+\$/|" "$OPTION_JS" + # Patch 2: disable single-char short flag restriction + sed -i "s|if (/\\^-\\[^-\\]\\[^-\\]/.test(unsupportedFlag))|if (false)|" "$OPTION_JS" + echo "[postinstall] Patched Commander.js for multi-char short flags" +fi