Skip to content

npm-published v1.0.2 missing --version/-v flag handling in bin/c7.js #9

@TheophilusChinomona

Description

@TheophilusChinomona

Description

The npm-published version of @vedanth/context7@1.0.2 is missing the --version/-v flag handling in bin/c7.js.

Expected Behavior

$ c7 --version
1.0.2

$ c7 -v
1.0.2

Actual Behavior

Both flags are silently ignored and the argument is treated as a library name query:

$ c7 --version
# → fetches docs for "version" (e.g. version_utils Python package)

$ c7 -v
# → fetches docs for "v" (V programming language)

Root Cause

The parseArgs function in bin/c7.js is missing the --version/-v branch, and the main function is missing the early-exit check:

// Missing in parseArgs:
else if (a === '--version' || a === '-v') { args.version = true; }

// Missing in main():
if (opts.version) {
    const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
    console.log(pkg.version);
    process.exit(0);
}

These lines exist in the GitHub repo source but were apparently omitted from the npm-published tarball. A re-publish (npm publish) should resolve it.

Fix

The lines above need to be added at:

  1. parseArgs (bin/c7.js line ~36): add the --version/-v branch after the --json branch
  2. main (bin/c7.js line ~97): add the opts.version early-exit block before the opts.help check

Both are already present in the GitHub repo — they just need to be included in the next npm publish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions