Skip to content

Instantly share code, notes, and snippets.

@timkock
Last active October 21, 2015 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timkock/fc66c47ed23c5c59ed36 to your computer and use it in GitHub Desktop.
Save timkock/fc66c47ed23c5c59ed36 to your computer and use it in GitHub Desktop.
Everyone needs some love
'use strict';
/////////////////////
// COLLECTIEF HUGS //
/////////////////////
// dependencies
var inquirer = require('inquirer')
, nyanstream = require('nyanstream')
, colors = require('colors')
, pace = require('pace')(100);
// helpers
var hugs = function (after) {
console.log('Hold on let me see what i can do...'.green);
setTimeout(function () {
var ctr = 0;
var progress = setInterval(function () {
if(ctr === 100) {
clearInterval(progress);
var cat = nyanstream();
cat.pipe(process.stdout);
cat.nyan();
} else {
pace.op();
ctr++;
}
}, after);
}, 2000);
};
// initiate prompt
inquirer.prompt([{
type: 'input',
name: 'name',
message: 'What\'s your name'
}], function (who) {
inquirer.prompt([{
type: 'list',
name: 'preference',
message: ':name, Do you want a hug?'.replace(':name', who.name),
choices: [
'Yes',
'No',
'No idea',
new inquirer.Separator(),
'Talk to the receptionnist'
]
}], function (answer) {
switch (answer.preference) {
case 'Yes':
console.log('Here you go bru!'.green.bold);
return hugs(50);
case 'No':
console.log('Oh yes you do :name!'.replace(':name', who.name).green.bold);
return hugs(50);
case 'No idea':
console.log('Don’t talk that jibberish :name, here you go bru!'.replace(':name', who.name).green.bold);
return hugs(50);
case 'Talk to the receptionnist':
console.log('Do we have one of those? Let me take a look!'.blue.inverse);
return hugs(50);
break;
}
});
});
npm install inquirer colors pace nyanstream
node hugs.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment