Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucasbento/is-package-dep
Parses the closest package.json file and returns whether it contains the dependency or not.
https://github.com/lucasbento/is-package-dep
dependency nodejs npm package yarn
Last synced: about 1 month ago
JSON representation
Parses the closest package.json file and returns whether it contains the dependency or not.
- Host: GitHub
- URL: https://github.com/lucasbento/is-package-dep
- Owner: lucasbento
- License: mit
- Created: 2017-10-03T08:31:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T10:36:50.000Z (about 7 years ago)
- Last Synced: 2024-11-20T16:03:58.581Z (about 2 months ago)
- Topics: dependency, nodejs, npm, package, yarn
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
is-package-dep
Parse the closest package.json file (upwards and downwards the tree) and returns whether a package is a dependency or not.## Why
Needed to check whether if a project has [react-native](https://github.com/facebook/react-native) as a dependency or not.## Install
```bash
yarn add is-package-dep # or npm i is-package-dep --save
```## Usage
```js
const isPackageDep = require('is-package-dep');const isRNProject = isPackageDep('react-native'); // value will be either `true` or `false`
```## API
### isPackageDep(packageName, [options])
Returns a boolean value that holds whether the package is installed or not.#### packageName
Type: `string`
The name of the package.#### options
##### baseDir
Type: `string`
Default: `process.cwd()`
Directory to start looking up for the `package.json` file.## License
MIT © [Lucas Bento](https://twitter.com/lbentosilva)---
Thanks to [Sindre Sorhus](https://github.com/sindresorhus) for [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) module.