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

detect-package-manager

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-package-manager - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

dist/index.d.ts

37

package.json
{
"name": "detect-package-manager",
"version": "1.1.0",
"version": "2.0.0",
"description": "Detect which package manager you're using (yarn or npm)",

@@ -9,5 +9,12 @@ "repository": {

},
"main": "index.js",
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
".": {
"require": "./dist/index.js",
"default": "./dist/index.mjs"
}
},
"files": [
"index.js"
"dist"
],

@@ -19,7 +26,9 @@ "keywords": [

"detect",
"check"
"check",
"pnpm"
],
"scripts": {
"test": "npm run lint && ava",
"lint": "xo"
"build": "tsup src/index.ts --format esm,cjs --dts",
"test": "node -r sucrase/register test.ts",
"prepublishOnly": "npm run build"
},

@@ -29,13 +38,15 @@ "author": "egoist <0x142857@gmail.com>",

"dependencies": {
"execa": "^0.8.0",
"path-exists": "^3.0.0"
"execa": "^5.1.1"
},
"devDependencies": {
"ava": "^0.21.0",
"eslint-config-rem": "^3.0.0",
"xo": "^0.18.0"
"@types/node": "^16.11.4",
"ava": "^3.15.0",
"sucrase": "^3.20.3",
"tsup": "^5.4.4",
"typescript": "^4.4.4",
"uvu": "^0.5.2"
},
"xo": {
"extends": "rem"
"engines": {
"node": ">=12"
}
}

@@ -8,5 +8,5 @@

1. When there's `yarn.lock` or `package-lock.json` in current working directory, it will skip other operations and directly resolves `yarn` or `npm`
2. When there's no lockfile was found, it checks if `yarn` command exists. If so it resolves `yarn` otherwise `npm`
3. Results are cached
1. When there's `yarn.lock`, `package-lock.json`, or `pnpm-lock.yaml` in current working directory, it will skip other operations and directly resolve `yarn`, `npm`, or `pnpm`.
2. When there's no lockfile found, it checks if `yarn` and `pnpm` command exists. If so, it resolves `yarn` or `pnpm` otherwise `npm`.
3. Results are cached.

@@ -22,8 +22,8 @@ ## Install

```js
const detectPackageManager = require('detect-package-manager')
const { detect } = require('detect-package-manager')
detectPackageManager()
detect()
.then(pm => {
console.log(pm)
//=> 'yarn' or 'npm'
//=> 'yarn', 'npm', or 'pnpm'
})

@@ -34,25 +34,22 @@ ```

### detectPackageManager([opts])
### detect([opts])
Return: `Promise<pm>`
- Arguments:
- `opts.cwd`: `string` Optional, defaults to `.`, the directory to look up `yarn.lock`, `package-lock.json`, or `pnpm-lock.yaml`.
- Returns: `Promise<PM>`
It returns a Promise resolving the name of package manager, could be either `npm` or `yarn`.
It returns a Promise resolving the name of package manager, could be `npm`, `yarn`, or `pnpm`.
#### opts
### getNpmVersion([pm])
##### cwd
- Arguments:
- `pm`: `string` Optional, defaults to `npm`, could be `npm`, `yarn`, or `pnpm`
- Returns: `Promise<string>`
Type: `string`<br>
Default: `.`
It returns a Promise resolving the version of npm or the package manager you specified.
The directory to look up `yarn.lock` or `package-lock.json`.
### clearCache()
### detectPackageManager.npmVersion()
- Returns: `void`
Return: `Promise<version>`
It returns a Promise resolving the version of npm.
### detectPackageManager.clearCache()
Clear cache.

@@ -59,0 +56,0 @@

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