Socket
Socket
Sign inDemoInstall

inquirer-npm-name

Package Overview
Dependencies
54
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    inquirer-npm-name

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


Version published
Weekly downloads
1.3K
decreased by-27.64%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

inquirer-npm-name NPM version Build Status Dependency Status Coverage percentage

Helper function using inquirer 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

$ npm install --save inquirer-npm-name

Usage

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:

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 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

Keywords

FAQs

Last updated on 01 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc