-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
144 lines (136 loc) · 3.33 KB
/
Copy pathindex.js
File metadata and controls
144 lines (136 loc) · 3.33 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const inquirer = require('inquirer')
const fs = require('fs')
const Employee = require('./lib/Employee')
const Engineer = require('./lib/Engineer')
const Intern = require('./lib/Intern')
const Manager = require('./lib/Manager')
const path = require('path')
const render = require('./lib/htmlRenderer')
const OUTPUT_DIR = path.resolve(__dirname, 'output')
const outputPath = path.join(OUTPUT_DIR, 'team.html')
const teamMember = []
function startPromp() {
// Promping Manager questions
inquirer
.prompt([
{
type: 'input',
name: 'name',
message: 'What is the managers name?',
},
{
type: 'input',
name: 'id',
message: 'What is the managers id?',
},
{
type: 'input',
name: 'email',
message: 'What is the managers email?',
},
{
type: 'input',
name: 'officeNumber',
message: 'What is the managers office number?',
},
])
.then((answers) => {
var { name, id, email, officeNumber } = answers
var manager = new Manager(name, id, email, officeNumber)
teamMember.push(manager)
//Creating a function to start adding more team member after promp Questions
startTeam()
})
}
const anotherOne = [
{
type: 'list',
name: 'nextEmployee',
message:
'Select the type of team member you would like to add next, if you are done select "Done" to generate your team ',
choices: ['Engineer', 'Intern', 'Done'],
},
]
function startTeam() {
inquirer.prompt(anotherOne).then((answers) => {
console.log(answers)
switch (answers.nextEmployee) {
case 'Engineer':
prompEng()
break
case 'Intern':
prompInt()
break
case 'Done':
console.log('Creating your team!')
makeTeam()
}
})
}
function prompEng() {
inquirer
.prompt([
{
type: 'input',
name: 'name',
message: "What is the Engineer's name?",
},
{
type: 'input',
name: 'id',
message: "What is the Engineer's ID?",
},
{
type: 'input',
name: 'email',
message: "What is the Engineer's email?",
},
{
type: 'input',
name: 'github',
message: "What is the Engineer's Github username?",
},
])
.then((answers) => {
var { name, id, email, github } = answers
var engineer = new Engineer(name, id, email, github)
teamMember.push(engineer)
//Creating a function to start adding more team member after promp Questions
startTeam()
})
}
function prompInt() {
inquirer
.prompt([
{
type: 'input',
name: 'name',
message: 'What is the Interns name?',
},
{
type: 'input',
name: 'id',
message: 'What is the Interns id?',
},
{
type: 'input',
name: 'email',
message: 'What is the Interns email?',
},
{
type: 'input',
name: 'school',
message: 'What is the school name?',
},
])
.then((answers) => {
var { name, id, email, school } = answers
var intern = new Intern(name, id, email, school)
teamMember.push(intern)
startTeam()
})
}
function makeTeam() {
fs.writeFileSync(outputPath, render(teamMember), 'utf-8')
}
startPromp()