Commit a5419a7 1 parent 5451baf commit a5419a7 Copy full SHA for a5419a7
File tree 2 files changed +19
-2
lines changed
packages/hardhat-core/src/internal/cli
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " hardhat " : patch
3
+ ---
4
+
5
+ Use ` npm_config_user_agent ` to determine what package manager to use for project creation
Original file line number Diff line number Diff line change @@ -554,12 +554,24 @@ function isInstalled(dep: string) {
554
554
return dep in allDependencies ;
555
555
}
556
556
557
+ function getProjectTypeFromUserAgent ( ) {
558
+ const userAgent = process . env . npm_config_user_agent ;
559
+ // Get first part of user agent string
560
+ const [ projectType ] = userAgent ?. split ( "/" ) ?? [ ] ;
561
+ return projectType ;
562
+ }
563
+
557
564
async function isYarnProject ( ) {
558
- return fsExtra . pathExists ( "yarn.lock" ) ;
565
+ return (
566
+ getProjectTypeFromUserAgent ( ) === "yarn" || fsExtra . pathExists ( "yarn.lock" )
567
+ ) ;
559
568
}
560
569
561
570
async function isPnpmProject ( ) {
562
- return fsExtra . pathExists ( "pnpm-lock.yaml" ) ;
571
+ return (
572
+ getProjectTypeFromUserAgent ( ) === "pnpm" ||
573
+ fsExtra . pathExists ( "pnpm-lock.yaml" )
574
+ ) ;
563
575
}
564
576
565
577
async function getProjectPackageManager ( ) : Promise < PackageManager > {
You can’t perform that action at this time.
0 commit comments