An open API service indexing awesome lists of open source software.

https://github.com/flet/can-haz-package

:hamburger: Check if an npm package name is valid and does not currently exist.
https://github.com/flet/can-haz-package

Last synced: over 1 year ago
JSON representation

:hamburger: Check if an npm package name is valid and does not currently exist.

Awesome Lists containing this project

README

          

# can-haz-package

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]

[npm-image]: https://img.shields.io/npm/v/can-haz-package.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/can-haz-package
[travis-image]: https://img.shields.io/travis/Flet/can-haz-package.svg?style=flat-square
[travis-url]: https://travis-ci.org/Flet/can-haz-package

Check if an npm package name is valid and does not currently exist.

uses [validate-npm-package-name](https://www.npmjs.com/package/validate-npm-package-name) to check naming rules and uses `npm view` (via [shelljs](https://www.npmjs.com/package/shelljs)) to check if the package exists.

The return values are set up to conform to [inquirer](https://www.npmjs.com/package/inquirer)'s validate function expectations.

Because of the reliance on `shelljs` and `npm`, this package will not work in the browser, sorry!

## Install

```
npm install can-haz-package
```

## Usage

```js
var canHazPackage = require('can-haz-package')

canHazPackage('this-should-never-be-taken-omg-whaaaat-999')
// reurns true

canHazPackage('standard')
// returns 'Sorry, that package name is taken! :('

canHazPackage(' ¯\_(ツ)_/¯ ')
// returns 'Package name does not conform to naming rules.'

```

## Contributing

Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.

## License

[ISC](LICENSE.md)