Skip to content

Instantly share code, notes, and snippets.

@geddski
Created April 28, 2016 17:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geddski/c42feb364f3c671d22b6390d82b8af8f to your computer and use it in GitHub Desktop.
Save geddski/c42feb364f3c671d22b6390d82b8af8f to your computer and use it in GitHub Desktop.
workaround for inquirer list type not working in windows
/**
* Abstraction around multichoice questions that works in windows, despite https://github.com/nodejs/node/issues/5384
* Uses arrow keys for non-windows and number selection for windows
*/
var inquirer = require("inquirer");
var isWindows = /^win/.test(process.platform);
module.exports = function(questions) {
if (!isWindows) {
return questions;
}
else {
questions.type = 'rawlist';
return questions;
}
}
inquirer.prompt([
multichoice({
type: 'list',
message: 'select a starter',
name: 'starter',
choices: ['hello world', 'manifest only']
})
], function(answers){
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment