pm-info
v3.2.0
Published
A simple utility to get the package manager information which used in the project
Downloads
103
Maintainers
Readme
pm-info
A simple utility to get the package manager information which used in the project
Install
# use pnpm
$ pnpm install -D pm-info
# use yarn
$ yarn add -D pm-info
# use npm
$ npm install -D pm-info
Usage
use import
import { pmInfo, pmInfoSync } from '@node-kit/pm-info'
pmInfo()
// or
pmInfoSync()
use require
const { pmInfo, pmInfoSync } = require('@node-kit/pm-info')
pmInfo()
// or
pmInfoSync()
API reference
- Usage:
pmInfo(cwd)
&pmInfoSync(cwd)
- Parameters:
| Param | Description | Type | Optional value | Required | Default value |
| ----- | ------------ | -------- | -------------- | -------- | ------------- |
| cwd | running path | string
| - | false
| - |
- Types:
declare type ModulesYML = Record<string, unknown> & {
packageManager: string
}
declare function normalizePMSpec(pm: string): PackageManager
declare interface PackageManager {
name: string
version?: string
}
declare function pmInfo(cwd?: string): Promise<PackageManager | null>
declare function pmInfoSync(cwd?: string): PackageManager | null
- Demos:
- simple use
import { pmInfo, pmInfoSync } from '@node-kit/pm-info'
pmInfo().then(info => {
console.log('The package manager is: ', info) // { name: 'pnpm', version: '7.26.1' } | null
})
console.log('The package manager is: ', pmInfoSync()) // { name: 'pnpm', version: '7.26.1' } | null
Issues & Support
Please open an issue here.