fix: manager install command

This commit is contained in:
Innei
2022-04-05 15:46:08 +08:00
parent 30efcfc9aa
commit b67db722c0
2 changed files with 12 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@mx-space/mx-server",
"version": "3.23.3",
"version": "3.23.4",
"author": "Innei <https://innei.ren>",
"private": true,
"license": "AGPLv3",
"dashboard": {
"repo": "mx-space/mx-admin",
"version": "3.16.12"
"version": "3.16.13"
},
"husky": {
"hooks": {

View File

@@ -51,6 +51,12 @@ const LOCKS: Record<string, PackageManager> = {
'package-lock.json': 'npm',
}
const INSTALL_COMMANDS: Record<PackageManager, string> = {
pnpm: 'install',
yarn: 'add',
npm: 'install',
}
export const installPKG = async (name: string, cwd: string) => {
let manager: PackageManager | null = null
for (const lock of Object.keys(LOCKS)) {
@@ -70,7 +76,9 @@ export const installPKG = async (name: string, cwd: string) => {
}
}
}
if (!manager) {
throw new Error('No package manager found')
}
cd(cwd)
await $`${manager} install ${name}`
await $`${manager} ${INSTALL_COMMANDS[manager]} ${name}`
}