-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
89 lines (75 loc) · 2.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env node
'use strict';
const names = require('./animation-name');
const inquirer = require('inquirer');
const chalk = require('chalk');
const title = chalk.bold.green;
const response = chalk.italic.green;
const resume = require('./resume.json');
const resumePrompts = {
type: 'list',
name: 'resumeOptions',
message: 'What would do you like to discover about me?',
choices: [...Object.keys(resume), 'Exit']
};
function main() {
const greeting = 'Hello, my name is Mattia Contessa, welcome to my resume\n';
if (process.stdout.columns > 111) {
let index = 0;
const interval = setInterval(_ => {
console.clear();
console.log(chalk.green(names[++index % 2]));
if (index === 14) {
clearInterval(interval);
console.log(greeting);
resumeHandler();
}
}, 100);
}
else {
console.clear();
console.log(greeting);
resumeHandler();
}
}
function resumeHandler() {
inquirer.prompt(resumePrompts).then(answer => {
if (answer.resumeOptions == 'Exit') {
return;
}
const option = answer.resumeOptions;
console.log(response('--------------------------------------'));
resume[`${option}`].forEach((info, ind) => {
if (typeof info === 'string') {
console.log(response(` ${info}`));
}
else {
Object.values(info).forEach((value, ind) => {
if (ind) {
console.log(response(` ${value}`));
}
else {
console.log(title(` ${value.padEnd(38)}`));
}
});
ind !== resume[`${option}`].length - 1 && console.log(response('--------------------------------------'));
}
});
console.log(response('--------------------------------------'));
inquirer
.prompt({
type: 'list',
name: 'exitBack',
message: 'Go back or Exit?',
choices: ['Back', 'Exit']
})
.then(choice => {
if (choice.exitBack == 'Back') {
resumeHandler();
} else {
return;
}
});
});
}
main();