This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5c650f
commit 069ae7c
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* @adonisjs/sink | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { resolve } from 'path' | ||
import { pathExistsSync } from 'fs-extra' | ||
|
||
/** | ||
* Returns the package manager in use by checking for the lock files | ||
* on the disk or by inspecting the "npm_execpath" | ||
*/ | ||
export function getPackageManager(appRoot: string): 'yarn' | 'pnpm' | 'npm' { | ||
if (pathExistsSync(resolve(appRoot, 'yarn.lock'))) { | ||
return 'yarn' | ||
} | ||
|
||
if (pathExistsSync(resolve(appRoot, 'pnpm-lock.yaml'))) { | ||
return 'pnpm' | ||
} | ||
|
||
return process.env.npm_execpath && process.env.npm_execpath.includes('yarn') | ||
? 'yarn' | ||
: process.env.npm_execpath && process.env.npm_execpath.includes('pnpm') | ||
? 'pnpm' | ||
: 'npm' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters