Skip to content

ewnd9/inquirer-question

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inquirer-question

Build Status

flexible promise-based enhancement for one question case with backward capability

Install

$ npm install inquirer-question --save

Usage

Before

const inquirer = require('inquirer-bluebird');

inquirer
  .prompt({
    type: 'list',
    name: 'q1',
    message: 'hi',
    choices: [
      'test-1',
      'test-2'
    ]
  })
  .then(function(result) {
    if (result.q1 === 'test-1') {
      return 1;
    } else if (result.q1 === 'test-2') {
      return 2;
    }
  });

Now

const inquirer = require('inquirer-question');

inquirer
  .prompt({
    type: 'list',
    message: 'hi',
    choices: {
      'test-1': function() {
        // some computatations
        return 1;
      },
      'test-2': 2
    }
  })
  .then(function(result) {
    console.log(result); //=> 1 or 2
  });

Related

License

MIT © ewnd9

About

flexible promise-based enhancement for one question case

Resources

Stars

Watchers

Forks

Packages

No packages published