-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: implement runtime package manager detection #164
base: main
Are you sure you want to change the base?
Conversation
This is nice idea!
|
@@ -109,6 +128,7 @@ const main = defineCommand({ | |||
uninstall: remove, | |||
un: remove, | |||
detect, | |||
"detect-runner": detectRunner, |
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.
It would be nice if we simplify to have nypm detect
that displays both detection results.
@@ -3,6 +3,7 @@ export type PackageManagerName = "npm" | "yarn" | "pnpm" | "bun"; | |||
export type PackageManager = { | |||
name: PackageManagerName; | |||
command: string; | |||
packageRunner?: string; |
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.
We might make it an array. It is a map of known args => package runner
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #164 +/- ##
===========================================
- Coverage 82.17% 58.03% -24.14%
===========================================
Files 6 5 -1
Lines 516 510 -6
Branches 71 85 +14
===========================================
- Hits 424 296 -128
- Misses 91 211 +120
- Partials 1 3 +2 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
This PR adds a
detectRuntimePackageManager
api function to detect the current package manager in runtime using thenpm-config-user-agent
environment variable. It also adds a refactor so thatargv
parsing can be a safe fallback in the event that the environment variable is not set.The possible usecases for this API include
I'm currently marking this as a draft because I'd appreciate suggestions on how to implement tests for this new API.
References