-
Notifications
You must be signed in to change notification settings - Fork 81
fix(cli-repl): add best guess about installation method to buildInfo()
MONGOSH-2915
#2551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a best guess about the installation method to the buildInfo()
function in the CLI REPL package. The implementation analyzes environment variables, file paths, and system properties to determine how MongoDB shell was installed.
- Adds
installationMethod
field toBuildInfo
interface with types for npx, homebrew, linux-system-wide, or other - Implements detection logic using environment variables and filesystem paths
- Updates build info type definitions to properly handle the new field
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
packages/cli-repl/src/build-info.ts | Adds installation method detection logic and updates interface |
packages/build/src/build-info.ts | Updates build info type definitions and removes unused import |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
process.execPath.startsWith('/usr/bin/') && | ||
(await fs.stat(process.execPath)).uid === 0 |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks if the file owner's UID is 0 (root), but this doesn't guarantee system-wide installation. Files in /usr/bin/
could be owned by root even in local installations. Consider checking if the current process has root privileges instead, or remove this condition since the path check may be sufficient.
process.execPath.startsWith('/usr/bin/') && | |
(await fs.stat(process.execPath)).uid === 0 | |
process.execPath.startsWith('/usr/bin/') |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ I don't think Copilot is making a lot of sense here?
packages/cli-repl/src/build-info.ts
Outdated
__filename.match(/\bhomebrew\b/i) && | ||
process.execPath.match(/\bhomebrew\b/) |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern /\\bhomebrew\\b/i
is duplicated. Consider extracting it to a constant to avoid repetition and make maintenance easier.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong feelings
buildInfo()
buildInfo()
MONGOSH-2915
No description provided.