can-haz-package
Version:
Check if an npm pacakge name is valid and does not exist.
48 lines (29 loc) • 1.39 kB
Markdown
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[]: https://img.shields.io/npm/v/can-haz-package.svg?style=flat-square
[]: https://www.npmjs.com/package/can-haz-package
[]: https://img.shields.io/travis/Flet/can-haz-package.svg?style=flat-square
[]: 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!
```
npm install can-haz-package
```
```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.'
```
Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
[](LICENSE.md)