Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created February 23, 2016 15:56
Show Gist options
  • Select an option

  • Save ajcrites/7952e72e2e7cca32ddcc to your computer and use it in GitHub Desktop.

Select an option

Save ajcrites/7952e72e2e7cca32ddcc to your computer and use it in GitHub Desktop.
'use strict';
const Promise = require("bluebird");
const prompt = Promise.promisifyAll(require("prompt"));
const inquirer = Promise.promisifyAll(require("inquirer"));
const inquirerp = require("inquirer-promise");
const co = require("co");
prompt.start();
co(function* () {
let result = yield prompt.getAsync(['name']);
console.log("Hello,", result.name);
const questions = [{type: "input", name: "name", message: "What's your name?"}];
// Cannot be immediately promisified since callback does not take an error argument
// result = yield inquirer.promptAsync(questions);
result = yield inquirerp.prompt(questions);
console.log("Hello,", result.name);
}).catch(console.error);
{
"name": "blo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"bluebird": "^3.3.1",
"co": "^4.6.0",
"inquirer": "^0.12.0",
"inquirer-promise": "0.0.3",
"prompt": "^1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment