Last active
October 21, 2015 10:31
-
-
Save timkock/fc66c47ed23c5c59ed36 to your computer and use it in GitHub Desktop.
Everyone needs some love
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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; | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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