inquirer-repo-exists

1.0.6 • Public • Published

inquirer-repo-exists

NPM version Build Status Dependency Status Coveralls Status

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:

  1. prompt an Inquirer prompt configuration.
  2. inquirer or any object with a obj.prompt() method.
  3. The callback who'll take the selected name as parameter.

License

MIT © Philipp Alferov

Package Sidebar

Install

npm i inquirer-repo-exists

Weekly Downloads

0

Version

1.0.6

License

MIT

Last publish

Collaborators

  • alferov