From 8a0967de835982c2a97ca0e9127ccfcbd6e0a423 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Thu, 8 Jan 2026 08:18:18 -0600 Subject: [PATCH] fix: add validation for --config-dir edge cases - Error when --config-dir is used without a path value - Error when --config-dir is combined with --local flag Co-Authored-By: Claude Opus 4.5 --- bin/install.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/install.js b/bin/install.js index f1b4ce6b1..b1f6d79ea 100755 --- a/bin/install.js +++ b/bin/install.js @@ -36,8 +36,14 @@ const hasLocal = args.includes('--local') || args.includes('-l'); // Parse --config-dir argument function parseConfigDirArg() { const configDirIndex = args.findIndex(arg => arg === '--config-dir' || arg === '-c'); - if (configDirIndex !== -1 && args[configDirIndex + 1]) { - return args[configDirIndex + 1]; + if (configDirIndex !== -1) { + const nextArg = args[configDirIndex + 1]; + // Error if --config-dir is provided without a value or next arg is another flag + if (!nextArg || nextArg.startsWith('-')) { + console.error(` ${yellow}--config-dir requires a path argument${reset}`); + process.exit(1); + } + return nextArg; } // Also handle --config-dir=value format const configDirArg = args.find(arg => arg.startsWith('--config-dir=') || arg.startsWith('-c=')); @@ -193,6 +199,9 @@ function promptLocation() { if (hasGlobal && hasLocal) { console.error(` ${yellow}Cannot specify both --global and --local${reset}`); process.exit(1); +} else if (explicitConfigDir && hasLocal) { + console.error(` ${yellow}Cannot use --config-dir with --local${reset}`); + process.exit(1); } else if (hasGlobal) { install(true); } else if (hasLocal) {