Skip to content

Commit 2a862bb

Browse files
committed
fix: auto-patch Commander.js multi-char short flags in postinstall
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.
1 parent 5ea0b18 commit 2a862bb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

scripts/postinstall.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,13 @@ STUBEOF
117117
fi
118118

119119
echo "[postinstall] Stubs created."
120+
121+
# ── Patch Commander.js for multi-char short flags ───────────────────────────
122+
OPTION_JS=$(find node_modules -path "*/commander/lib/option.js" -type f | head -1)
123+
if [ -n "$OPTION_JS" ]; then
124+
# Patch 1: shortFlagExp — allow one or more chars after dash
125+
sed -i "s|shortFlagExp = /\^-\\[^-\\]\\$/|shortFlagExp = /\^-[^-]+\$/|" "$OPTION_JS"
126+
# Patch 2: disable single-char short flag restriction
127+
sed -i "s|if (/\\^-\\[^-\\]\\[^-\\]/.test(unsupportedFlag))|if (false)|" "$OPTION_JS"
128+
echo "[postinstall] Patched Commander.js for multi-char short flags"
129+
fi

0 commit comments

Comments
 (0)