Install
# use pnpm
$ pnpm install what-pm
# use yarn
$ yarn add what-pm
# use npm
$ npm install what-pm
Usage
use what-pm
in terminal
npx what-pm
# or
npx whatpm
# output: pnpm
use import
import { whatPM, whatPMSync } from '@node-kit/what-pm'
whatPM()
// or
whatPMSync()
use require
const { whatPM, whatPMSync } = require('@node-kit/what-pm')
whatPM()
// or
whatPMSync()
API reference
- Usage:
whatPM(pkgPath)
&whatPMSync(pkgPath)
- Parameters:
Param | Description | Type | Optional value | Required | Default value |
---|---|---|---|---|---|
pkgPath | package path | string |
- | true |
- |
- Types:
declare function whatPM(pkgPath: string): Promise<WhatPMResult | null>
declare interface WhatPMResult {
name: string
version: string
isWorkspace: boolean
}
declare function whatPMSync(pkgPath: string): WhatPMResult | null
- Demos:
- simple use
import { whatPM, whatPMSync } from '@node-kit/what-pm'
whatPM().then(info => {
console.log('The package manager is: ', info) // pnpm | null
})
console.log('The package manager is: ', whatPMSync()) // pnpm | null
Issues & Support
Please open an issue here.