Skip to content

Commit ddde2b5

Browse files
committed
feat: allow the getPakageInstallCommand to also check general installs.
1 parent ba4b2b1 commit ddde2b5

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@h3ravel/shared",
3-
"version": "0.20.5",
3+
"version": "0.20.6",
44
"description": "Shared Utilities.",
55
"type": "module",
66
"main": "./dist/index.js",

packages/shared/src/Utils/Resolver.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ import crypto from 'crypto'
22
import preferredPM from 'preferred-pm'
33

44
export class Resolver {
5-
static async getPakageInstallCommand (pkg: string) {
5+
static async getPakageInstallCommand (pkg?: string) {
6+
const pm = (await preferredPM(process.cwd()))?.name ?? 'pnpm'
7+
8+
let cmd = 'install '
9+
10+
if (!pkg) {
11+
if (pm === 'npm' || pm === 'pnpm' || pm === 'bun')
12+
cmd = 'install'
13+
else
14+
cmd = ''
15+
} else if (pm === 'yarn' || pm === 'pnpm' || pm === 'bun')
16+
cmd = 'add '
17+
18+
return `${pm} ${cmd}${pkg ?? ''}`
19+
}
20+
21+
static async getInstallCommand (pkg: string) {
622
const pm = (await preferredPM(process.cwd()))?.name ?? 'pnpm'
723

824
let cmd = 'install'
@@ -14,6 +30,7 @@ export class Resolver {
1430
return `${pm} ${cmd} ${pkg}`
1531
}
1632

33+
1734
/**
1835
* Create a hash for a function or an object
1936
*

0 commit comments

Comments
 (0)