@capgo/find-package-manager
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -7,2 +7,2 @@ export type PackageManagerType = 'yarn' | 'npm' | 'bun' | 'pnpm' | 'unknown'; | ||
export function findInstallCommand (packageManagerType?: PackageManagerType): InstallCommand; | ||
export function findPackageManagerRuuner (path?: string, defaultPackageManagerRunner?: PackageManagerRunner); | ||
export function findPackageManagerRunner (path?: string, defaultPackageManagerRunner?: PackageManagerRunner); |
16
main.js
@@ -23,20 +23,20 @@ import { existsSync } from 'fs'; | ||
export const findInstallCommand = (packageManagerType = findPackageManagerType()) => { | ||
export const findInstallCommand = (packageManagerType = findPackageManagerType(), prefix = false) => { | ||
switch (packageManagerType) { | ||
case 'bun': | ||
return 'install'; | ||
return prefix ? 'bun install' : 'install'; | ||
case 'pnpm': | ||
return 'install'; | ||
return prefix ? 'pnpm install' : 'install'; | ||
case 'yarn': | ||
return 'add'; | ||
return prefix ? 'yarn install' : 'install'; | ||
case 'npm': | ||
return 'install'; | ||
return prefix ? 'npm install' : 'install'; | ||
case 'unknown': | ||
return 'unknown'; | ||
return prefix ? 'unknown unknown' : 'unknown'; | ||
default: | ||
return 'install'; | ||
return prefix ? 'npm install' : 'install'; | ||
} | ||
} | ||
export const findPackageManagerRuuner = (path = '.', defaultPackageManagerRunner = 'npx') => { | ||
export const findPackageManagerRunner = (path = '.', defaultPackageManagerRunner = 'npx') => { | ||
const bunPath = `${path}/bun.lockb`; | ||
@@ -43,0 +43,0 @@ const pnpmPath = `${path}/pnpm-lock.yaml`; |
@@ -5,5 +5,5 @@ { | ||
"public": true, | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"license": "MIT", | ||
"description": "Live update for capacitor apps", | ||
"description": "Find the package manager of a project", | ||
"main": "main.js", | ||
@@ -10,0 +10,0 @@ "module": "main.js", |
@@ -10,2 +10,30 @@ # Find Package Manager Type | ||
console.log(findPackageManagerType()) // npm | yarn | pnpm | bun | unknown | ||
// Provide a path | ||
console.log(findPackageManagerType('../.')) // npm | yarn | pnpm | bun | unknown | ||
// Provide a default manager | ||
console.log(findPackageManagerType('.', 'npm')) // npm | yarn | pnpm | bun | ||
``` | ||
Find the install command for the package manager. | ||
```typescript | ||
import { findInstallCommand } from '@capgo/find-package-manager' | ||
console.log(findInstallCommand()) // install | add | unknown | ||
// Provide the manager instead of read it with default folder '.' | ||
console.log(findInstallCommand(findPackageManagerType())) // install | add | unknown | ||
// Provide the manager and ask to return it prefixed | ||
console.log(findInstallCommand(findPackageManagerType(), true)) // npm install | yarn add | pnpm add | bun add | unknown unknown | ||
``` | ||
Find the package runner command. | ||
```typescript | ||
import { findPackageManagerRunner } from '@capgo/find-package-manager' | ||
console.log(findPackageManagerRunner()) // 'yarn dlx' | 'npx' | 'bunx' | 'pnpm exec' | ||
// Provide the path to search for | ||
console.log(findPackageManagerRunner('../.')) // 'yarn dlx' | 'npx' | 'bunx' | 'pnpm exec' | ||
// Provide a default manager | ||
console.log(findPackageManagerRunner('.', 'yarn')) // 'yarn dlx' | 'npx' | 'bunx' | 'pnpm exec' | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4583
39