lucasbento / is-package-dep

Parses the closest package.json file and returns whether it contains the dependency or not.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 as a dependency or not.

Install

yarn add is-package-dep # or npm i is-package-dep --save

Usage

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


Thanks to Sindre Sorhus for read-pkg-up module.

About

Parses the closest package.json file and returns whether it contains the dependency or not.

License:MIT License


Languages

Language:JavaScript 100.0%