1.0.0 • Published 10 months ago

@cityssm/has-package v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Has Package

NPM Version Maintainability DeepSource codecov

Tests if a package is available to be imported. Useful for checking if optional dependencies are installed.

Unlike other packages that test whether a package is available by importing it, this package checks the file system for the corresponding package.json file. This avoids any package code from running during the check.

Installation

npm install @cityssm/has-package

Usage

import hasPackage from '@cityssm/has-package'

/*
 * Test for an existing package
 */

let packageExists = await hasPackage('eslint')
console.log(packageExists)
// => true

/*
 * Test for an nonexisting package
 */

packageExists = await hasPackage('@cityssm/non-existing-package')
console.log(packageExists)
// => false
1.0.0

10 months ago

0.1.1

11 months ago

0.1.0

11 months ago