Skip to content

Commit

Permalink
es6ification of the code base, bye bye gulp, hello Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Nov 12, 2017
1 parent 70174ed commit 5b4253c
Show file tree
Hide file tree
Showing 63 changed files with 4,011 additions and 4,058 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
.nyc_output
.idea
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
sudo: false
language: node_js
node_js:
- 4
- 6
- node
- 4
- 6
- 8
- node
cache:
yarn: true
after_success:
- npm run coverage
env:
global:
secure: dHdnulkfL3Es9kaH0JVFwPk5VUeD7fdiMYdNaId09ZTa9mL9BvYcHmeVK5g1ZIm1F0+QmLeJwjO+4dq1yjRz6IFnpbgQSlhIbYjs+8zBc1v+HTZZfB/kFRIqHO0x4nJG8vKVa+Sg5tp0pI7hiCgevsrlvf4Pb6D0Cyx+faSGNrY=
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Array values can be simple `strings`, or `objects` containing a `name` (to displ
``` javascript
{
/* Preferred way: with promise */
filter: function () {
filter() {
return new Promise(/* etc... */);
},

Expand All @@ -131,7 +131,7 @@ Array values can be simple `strings`, or `objects` containing a `name` (to displ
var done = this.async();

// Do async stuff
setTimeout(function () {
setTimeout(() => {
if (typeof input !== 'number') {
// Pass the return value in the done callback
done('You need to provide a number');
Expand Down
15 changes: 5 additions & 10 deletions examples/bottom-bar.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
var BottomBar = require('../lib/ui/bottom-bar');
var cmdify = require('cmdify');

var loader = [
'/ Installing',
'| Installing',
'\\ Installing',
'- Installing'
];
var loader = ['/ Installing', '| Installing', '\\ Installing', '- Installing'];
var i = 4;
var ui = new BottomBar({bottomBar: loader[i % 4]});
var ui = new BottomBar({ bottomBar: loader[i % 4] });

setInterval(function () {
setInterval(() => {
ui.updateBottomBar(loader[i++ % 4]);
}, 300);

var spawn = require('child_process').spawn;

var cmd = spawn(cmdify('npm'), ['-g', 'install', 'inquirer'], {stdio: 'pipe'});
var cmd = spawn(cmdify('npm'), ['-g', 'install', 'inquirer'], { stdio: 'pipe' });
cmd.stdout.pipe(ui.log);
cmd.on('close', function () {
cmd.on('close', () => {
ui.updateBottomBar('Installation done!\n');
process.exit();
});
116 changes: 59 additions & 57 deletions examples/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,64 @@
'use strict';
var inquirer = require('..');

inquirer.prompt([
{
type: 'checkbox',
message: 'Select toppings',
name: 'toppings',
choices: [
new inquirer.Separator(' = The Meats = '),
{
name: 'Pepperoni'
},
{
name: 'Ham'
},
{
name: 'Ground Meat'
},
{
name: 'Bacon'
},
new inquirer.Separator(' = The Cheeses = '),
{
name: 'Mozzarella',
checked: true
},
{
name: 'Cheddar'
},
{
name: 'Parmesan'
},
new inquirer.Separator(' = The usual ='),
{
name: 'Mushroom'
},
{
name: 'Tomato'
},
new inquirer.Separator(' = The extras = '),
{
name: 'Pineapple'
},
{
name: 'Olives',
disabled: 'out of stock'
},
{
name: 'Extra cheese'
inquirer
.prompt([
{
type: 'checkbox',
message: 'Select toppings',
name: 'toppings',
choices: [
new inquirer.Separator(' = The Meats = '),
{
name: 'Pepperoni'
},
{
name: 'Ham'
},
{
name: 'Ground Meat'
},
{
name: 'Bacon'
},
new inquirer.Separator(' = The Cheeses = '),
{
name: 'Mozzarella',
checked: true
},
{
name: 'Cheddar'
},
{
name: 'Parmesan'
},
new inquirer.Separator(' = The usual ='),
{
name: 'Mushroom'
},
{
name: 'Tomato'
},
new inquirer.Separator(' = The extras = '),
{
name: 'Pineapple'
},
{
name: 'Olives',
disabled: 'out of stock'
},
{
name: 'Extra cheese'
}
],
validate: function(answer) {
if (answer.length < 1) {
return 'You must choose at least one topping.';
}
return true;
}
],
validate: function (answer) {
if (answer.length < 1) {
return 'You must choose at least one topping.';
}
return true;
}
}
]).then(function (answers) {
console.log(JSON.stringify(answers, null, ' '));
});
])
.then(answers => {
console.log(JSON.stringify(answers, null, ' '));
});
4 changes: 2 additions & 2 deletions examples/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var questions = [
type: 'editor',
name: 'bio',
message: 'Please write a short bio of at least 3 lines.',
validate: function (text) {
validate: function(text) {
if (text.split('\n').length < 3) {
return 'Must be at least 3 lines.';
}
Expand All @@ -20,6 +20,6 @@ var questions = [
}
];

inquirer.prompt(questions).then(function (answers) {
inquirer.prompt(questions).then(answers => {
console.log(JSON.stringify(answers, null, ' '));
});
66 changes: 34 additions & 32 deletions examples/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@
'use strict';
var inquirer = require('..');

inquirer.prompt([
{
type: 'expand',
message: 'Conflict on `file.js`: ',
name: 'overwrite',
choices: [
{
key: 'y',
name: 'Overwrite',
value: 'overwrite'
},
{
key: 'a',
name: 'Overwrite this one and all next',
value: 'overwrite_all'
},
{
key: 'd',
name: 'Show diff',
value: 'diff'
},
new inquirer.Separator(),
{
key: 'x',
name: 'Abort',
value: 'abort'
}
]
}
]).then(function (answers) {
console.log(JSON.stringify(answers, null, ' '));
});
inquirer
.prompt([
{
type: 'expand',
message: 'Conflict on `file.js`: ',
name: 'overwrite',
choices: [
{
key: 'y',
name: 'Overwrite',
value: 'overwrite'
},
{
key: 'a',
name: 'Overwrite this one and all next',
value: 'overwrite_all'
},
{
key: 'd',
name: 'Show diff',
value: 'diff'
},
new inquirer.Separator(),
{
key: 'x',
name: 'Abort',
value: 'abort'
}
]
}
])
.then(answers => {
console.log(JSON.stringify(answers, null, ' '));
});
42 changes: 24 additions & 18 deletions examples/hierarchical.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ function main() {
}

function exitHouse() {
inquirer.prompt(directionsPrompt).then(function (answers) {
inquirer.prompt(directionsPrompt).then(answers => {
if (answers.direction === 'Forward') {
console.log('You find yourself in a forest');
console.log('There is a wolf in front of you; a friendly looking dwarf to the right and an impasse to the left.');
console.log(
'There is a wolf in front of you; a friendly looking dwarf to the right and an impasse to the left.'
);
encounter1();
} else {
console.log('You cannot go that way. Try again');
Expand All @@ -31,11 +33,13 @@ function exitHouse() {
}

function encounter1() {
inquirer.prompt(directionsPrompt).then(function (answers) {
inquirer.prompt(directionsPrompt).then(answers => {
var direction = answers.direction;
if (direction === 'Forward') {
console.log('You attempt to fight the wolf');
console.log('Theres a stick and some stones lying around you could use as a weapon');
console.log(
'Theres a stick and some stones lying around you could use as a weapon'
);
encounter2b();
} else if (direction === 'Right') {
console.log('You befriend the dwarf');
Expand All @@ -49,7 +53,7 @@ function encounter1() {
}

function encounter2a() {
inquirer.prompt(directionsPrompt).then(function (answers) {
inquirer.prompt(directionsPrompt).then(answers => {
var direction = answers.direction;
if (direction === 'Forward') {
var output = 'You find a painted wooden sign that says:';
Expand All @@ -67,19 +71,21 @@ function encounter2a() {
}

function encounter2b() {
inquirer.prompt({
type: 'list',
name: 'weapon',
message: 'Pick one',
choices: [
'Use the stick',
'Grab a large rock',
'Try and make a run for it',
'Attack the wolf unarmed'
]
}).then(function () {
console.log('The wolf mauls you. You die. The end.');
});
inquirer
.prompt({
type: 'list',
name: 'weapon',
message: 'Pick one',
choices: [
'Use the stick',
'Grab a large rock',
'Try and make a run for it',
'Attack the wolf unarmed'
]
})
.then(() => {
console.log('The wolf mauls you. You die. The end.');
});
}

main();

0 comments on commit 5b4253c

Please sign in to comment.