-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor: update package manager detection and improve type handling #9067
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
refactor: update package manager detection and improve type handling #9067
Conversation
- Replaced the `detect` and `getPackageManagerVersion` functions with a new `detectPackageManager` function for better clarity and type safety. - Updated the `PM` type to an enum for improved maintainability. - Adjusted the logic in `getCollectorByPackageManager` and `installDependencies` to utilize the new detection method. - Cleaned up unused code and comments in `packageManager.ts` and `yarn.ts` files.
🦋 Changeset detectedLatest commit: 210f3cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
- Renamed `detectPackageManager` to `detectPackageManagerByEnv` for clarity. - Improved the logic in `detectPackageManager` to handle multiple lock files and prioritize detection based on existing files. - Updated the `installDependencies` function to correctly handle Yarn Berry cases. - Cleaned up code for better readability and maintainability.
Should we directly determine the package manager based on the env, and completely remove the logic that determines it based on the lock file? Could you check if this might cause any other issues? |
Hmmm, I think we should emulate the approach that electron-builder took prior to the |
@mmaietta The current logic has been changed: if there is only one lock file, the lock file will be used to determine the package manager (PM). If there are multiple lock files or no lock file, the environment variables ( |
- Introduced `getPackageManagerCommand` to standardize command retrieval for package managers. - Updated imports in `index.ts` and `yarn.ts` to include the new function. - Removed the deprecated `getPackageToolPath` function for cleaner code.
fix #8970 (comment)
detect
andgetPackageManagerVersion
functions with a newdetectPackageManager
function for better clarity and type safety.PM
type to an enum for improved maintainability.getCollectorByPackageManager
andinstallDependencies
to utilize the new detection method.packageManager.ts
andyarn.ts
files.