From 76bf190d75ceace343b1e4e9223888272b7c8853 Mon Sep 17 00:00:00 2001 From: emanmunirabark Date: Wed, 18 Mar 2026 15:52:45 +0500 Subject: [PATCH] fix: correct --force flag logic in update and add --limit validation in search Two small bug fixes: 1. update.js: `opts.force || true` always evaluates to true, making the --force flag a no-op. `fetchAllRegistries` defaults its parameter to false, so passing `opts.force` (undefined when omitted) correctly falls back to cache-aware behavior while still honoring --force when the user explicitly sets it. 2. search.js: `parseInt(opts.limit, 10)` can produce NaN when a non-numeric value is passed (e.g. `--limit abc`). `Array.slice(0, NaN)` returns an empty array, silently hiding all results. Added `|| 20` fallback to match the declared default. Made-with: Cursor --- cli/src/commands/search.js | 2 +- cli/src/commands/update.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/search.js b/cli/src/commands/search.js index ee4b7624..9f49a32b 100644 --- a/cli/src/commands/search.js +++ b/cli/src/commands/search.js @@ -56,7 +56,7 @@ export function registerSearchCommand(program) { .option('--limit ', 'Max results', '20') .action((query, opts) => { const globalOpts = program.optsWithGlobals(); - const limit = parseInt(opts.limit, 10); + const limit = parseInt(opts.limit, 10) || 20; // No query: list all if (!query) { diff --git a/cli/src/commands/update.js b/cli/src/commands/update.js index c32d9f78..0efec4d5 100644 --- a/cli/src/commands/update.js +++ b/cli/src/commands/update.js @@ -31,7 +31,7 @@ export function registerUpdateCommand(program) { ); } else { info('Updating registries...'); - const errors = await fetchAllRegistries(opts.force || true); + const errors = await fetchAllRegistries(opts.force); if (errors.length > 0) { for (const e of errors) { process.stderr.write(chalk.yellow(`Warning: ${e.source}: ${e.error}\n`));