Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capgo/find-package-manager

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capgo/find-package-manager - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

2

index.d.ts

@@ -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);

@@ -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'
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc