inquirer-repo-exists
v1.0.6
Published
Helper function using inquirer to validate whether a URL (or a username/repo pair) provided in a prompt refers to an existing GitHub repository
Downloads
5
Maintainers
Readme
inquirer-repo-exists
Helpe
Helper function using inquirer to validate whether a URL (or a username/repo pair) provided in a prompt refers to an existing GitHub repository URL
If the provided URL (or a username/repo pair) doesn't refer to an existing GitHub repository, 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 valid GitHub repository link.
Install
$ npm install --save inquirer-repo-exist
Usage
var inquirer = require('inquirer');
var repoExists = require('inquirer-repo-exists');
repoExists({
name: 'repoUrl',
message: 'GitHub repository link (username/repo pair)'
}, inquirer, function (repoUrl) {
console.log(repoUrl);
});
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 () {
var done = this.async();
askName({
name: 'repoUrl',
message: 'GitHub repository link (username/repo pair)'
}, this, function (repoUrl) {
console.log(repoUrl);
done();
});
}
});
repoUrl
takes 3 parameters:
prompt
an Inquirer prompt configuration.inquirer
or any object with aobj.prompt()
method.- The
callback
who'll take the selected name as parameter.
License
MIT © Philipp Alferov