|
|
1 年之前 | |
|---|---|---|
| .. | ||
| dist | 1 年之前 | |
| LICENSE | 1 年之前 | |
| README.md | 1 年之前 | |
| package.json | 1 年之前 | |
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.yarn and pnpm command exists. If so, it resolves yarn or pnpm otherwise npm.yarn add detect-package-manager
const { detect } = require('detect-package-manager')
detect()
.then(pm => {
console.log(pm)
//=> 'yarn', 'npm', or 'pnpm'
})
opts.cwd: string Optional, defaults to ., the directory to look up yarn.lock, package-lock.json, or pnpm-lock.yaml.Promise<PM>It returns a Promise resolving the name of package manager, could be npm, yarn, or pnpm.
pm: string Optional, defaults to npm, could be npm, yarn, or pnpmPromise<string>It returns a Promise resolving the version of npm or the package manager you specified.
voidClear cache.
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-featuredetect-package-manager © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
github.com/egoist · GitHub @EGOIST · Twitter @_egoistlily