# inquirer-npm-name

> Helper function using inquirer to validate a value provided in a prompt does not exist as an npm package.

Latest version **4.0.0** (published 2021-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install inquirer-npm-name
pnpm add inquirer-npm-name
yarn add inquirer-npm-name
bun add inquirer-npm-name
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-03-01 |
| First published | 2015-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/inquirer-npm-name) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Simon Boudrias |
| Maintainers | sboudrias |
| Keywords | inquirer, npm, name, yeoman, package |

## Links

- npm: https://www.npmjs.com/package/inquirer-npm-name
- Repository: https://github.com/SBoudrias/inquirer-npm-name
- Homepage: https://github.com/SBoudrias/inquirer-npm-name#readme
- Issues: https://github.com/SBoudrias/inquirer-npm-name/issues
- npm.io page: https://npm.io/package/inquirer-npm-name

## Dependencies (3)

- [npm-name](https://npm.io/package/npm-name.md) ^6.0.1
- [upper-case-first](https://npm.io/package/upper-case-first.md) ^2.0.2
- [validate-npm-package-name](https://npm.io/package/validate-npm-package-name.md) ^3.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2021-03-01
- 3.0.0 — 2017-12-29
- 2.0.0 — 2016-05-08
- 1.0.0 — 2015-08-06

## README

# inquirer-npm-name [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]

Helper function using [inquirer](https://github.com/SBoudrias/Inquirer.js) to
validate a value provided in a prompt does not exist as a npm package.

The supplied value must be a valid package name (as per
[validate-npm-package-name]); otherwise, the user will again be prompted to
enter a name.

If the value is already used as a npm package, then the users will be prompted
and asked if they want to choose another one. If so, we'll recurse through the
same validation process until we have a name that is unused on the npm registry.
This is a helper to catch naming issue in advance, it is not a validation rule
as the user can always decide to continue with the same name.

## Install

```sh
$ npm install --save inquirer-npm-name
```

## Usage

```js
var inquirer = require('inquirer');
var askName = require('inquirer-npm-name');

askName(
  {
    name: 'name',
    message: 'Some Module Name' // Default: 'Module Name'
  },
  inquirer
).then(function(answer) {
  console.log(answer.name);
});

// Equivalent to {name: 'name'}
askName('name', inquirer).then(function(answer) {
  console.log(answer.name);
});
```

Inside a **Yeoman Generator** you'd call it this way:

```js
var generators = require('yeoman-generator');
var inquirer = require('inquirer');
var askName = require('inquirer-npm-name');

module.exports = generators.Base.extend({
  prompting: function() {
    return askName(
      {
        name: 'name',
        message: 'Module Name'
      },
      this
    ).then(function(name) {
      console.log(name);
    });
  }
});
```

`askName` takes 2 parameters:

1. `prompt` an [Inquirer prompt configuration](https://github.com/SBoudrias/Inquirer.js#question)
   or just a string to serve as name.
2. `inquirer` or any object with a `obj.prompt()` method.

**Returns:** A `Promise` resolved with the answer object.

## License

MIT © [Simon Boudrias](http://twitter.com/vaxilart)

[validate-npm-package-name]: https://npmjs.org/package/validate-npm-package-name
[npm-image]: https://badge.fury.io/js/inquirer-npm-name.svg
[npm-url]: https://npmjs.org/package/inquirer-npm-name
[travis-image]: https://travis-ci.org/SBoudrias/inquirer-npm-name.svg?branch=master
[travis-url]: https://travis-ci.org/SBoudrias/inquirer-npm-name
[daviddm-image]: https://david-dm.org/SBoudrias/inquirer-npm-name.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/SBoudrias/inquirer-npm-name
[coveralls-image]: https://coveralls.io/repos/SBoudrias/inquirer-npm-name/badge.svg
[coveralls-url]: https://coveralls.io/r/SBoudrias/inquirer-npm-name

---
_Source: https://npm.io/package/inquirer-npm-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
