what-pm
Version:
Detects what package manager was used for installation
123 lines (84 loc) • 2.68 kB
Markdown
<div style="text-align: center;" align="center">
Detects what package manager was used for installation
[![NPM version][npm-image]][npm-url]
[![Codacy Badge][codacy-image]][codacy-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]
[![License][license-image]][license-url]
[![Sonar][sonar-image]][sonar-url]
</div>
```bash
$ pnpm install what-pm
$ yarn add what-pm
$ npm install what-pm
```
use `what-pm` in terminal
```bash
npx what-pm
npx whatpm
```
use import
```js
import { whatPM, whatPMSync } from 'what-pm'
whatPM()
// or
whatPMSync()
```
use require
```js
const { whatPM, whatPMSync } = require('what-pm')
whatPM()
// or
whatPMSync()
```
- Usage: `whatPM(pkgPath)` & `whatPMSync(pkgPath)`
- Parameters:
<div class="table-prop">
| Param | Description | Type | Optional value | Required | Default value |
| ------- | ------------ | -------- | -------------- | -------- | ------------- |
| pkgPath | package path | `string` | - | `true` | - |
</div>
- Types:
```ts
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:
1. simple use
```ts
import { whatPM, whatPMSync } from 'what-pm'
whatPM().then(info => {
console.log('The package manager is: ', info) // pnpm | null
})
console.log('The package manager is: ', whatPMSync()) // pnpm | null
```
Please open an issue [here](https://github.com/saqqdy/node-kit/issues).
[](LICENSE)
[]: https://img.shields.io/npm/v/what-pm.svg?style=flat-square
[]: https://npmjs.org/package/what-pm
[]: https://app.codacy.com/project/badge/Grade/f70d4880e4ad4f40aa970eb9ee9d0696
[]: https://www.codacy.com/gh/saqqdy/what-pm/dashboard?utm_source=github.com&utm_medium=referral&utm_content=saqqdy/what-pm&utm_campaign=Badge_Grade
[]: https://img.shields.io/codecov/c/github/saqqdy/what-pm.svg?style=flat-square
[]: https://codecov.io/github/saqqdy/what-pm?branch=master
[]: https://img.shields.io/npm/dm/what-pm.svg?style=flat-square
[]: https://npmjs.org/package/what-pm
[]: https://img.shields.io/badge/License-MIT-blue.svg
[]: LICENSE
[]: https://sonarcloud.io/api/project_badges/quality_gate?project=saqqdy_node-kit
[]: https://sonarcloud.io/dashboard?id=saqqdy_node-kit