Package Exports
- inquirer-npm-name
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inquirer-npm-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
inquirer-npm-name

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-nameUsage
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:
promptan Inquirer prompt configuration or just a string to serve as name.inquireror any object with aobj.prompt()method.
Returns: A Promise resolved with the answer object.
License
MIT © Simon Boudrias