@node-kit/which-pm
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

@node-kit/which-pm

A simple utility to get which package manager used in the project

NPM version Codacy Badge Test coverage npm download License

Sonar

Install

# use pnpm
$ pnpm install -D @node-kit/which-pm

# use yarn
$ yarn add -D @node-kit/which-pm

# use npm
$ npm install -D @node-kit/which-pm

Usage

use @node-kit/which-pm in terminal

npx which-pm

# output: pnpm@7.26.1 | null

use import

import { whichPM, whichPMSync } from '@node-kit/which-pm'

whichPM()
// or
whichPMSync()

use require

const { whichPM, whichPMSync } = require('@node-kit/which-pm')

whichPM()
// or
whichPMSync()

API reference

  • Usage: whichPM([cwd, withVersion]) & whichPMSync([cwd, withVersion])
  • Parameters:
Param Description Type Optional value Required Default value
cwd running path string - false -
withVersion return with version boolean - false true
  • Types:
declare function whichPM(cwd?: string, withVersion?: boolean): Promise<string | null>

declare function whichPMSync(cwd?: string, withVersion?: boolean): string | null
  • Demos:
  1. simple use
import { whichPM, whichPMSync } from '@node-kit/which-pm'

whichPM().then(path => {
  console.log('The package manager is: ', path) // pnpm@7.26.1 | null
})

console.log('The package manager is: ', whichPMSync()) // pnpm@7.26.1 | null

Issues & Support

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @node-kit/which-pm

Weekly Downloads

2

Version

3.2.0

License

MIT

Unpacked Size

10.1 kB

Total Files

8

Last publish

Collaborators

  • saqqdy