-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
160 lines (143 loc) · 4.19 KB
/
app.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
const Employee = require("./lib/Employee")
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const inquirer = require("inquirer");
const path = require("path");
const fs = require("fs");
const render = require('./lib/htmlRenderer');
const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");
const teamArray = [];
// Write code to use inquirer to gather information about the development team members,
// and to create objects for each team member (using the correct classes as blueprints!)
const createTeam = () => {
if (!fs.existsSync(OUTPUT_DIR)) {
fs.mkdirSync(OUTPUT_DIR)
}
fs.writeFile(outputPath, render(teamArray), err => {
if (err) {
return console.log(err);
} else {
console.log("Hacking the system")
}
})
}
function init() {
inquirer.prompt([
{
type: "input",
message: "What is your team manager's name?",
name: "name"
}, {
type: "input",
message: "What is your id?",
name: "id"
},
{
type: "input",
message: "What is your team manager's email address?",
name: "email"
},
{
type: "number",
message: "What is your team manager's office number?",
name: "officeNumber"
}
]).then(({name, id, email, officeNumber})=> {
const manager = new Manager(name, id, email, officeNumber)
teamArray.push(manager);
addTeamMembers();
});
}
function addTeamMembers() {
inquirer.prompt([
{
type: "list",
message: "Who would you like to work to death?",
choices: ["A hopless Intern", "A suspicous Engineer", "None because you're broke"],
name: "choices"
}
]).then(({choices}) => {
switch (choices) {
case "A hopless Intern":
addIntern();
break;
case "A suspicous Engineer":
addEngineer();
break;
case "None because you're broke":
createTeam();
break;
}
;
})
}
function addIntern() {
inquirer.prompt([
{
type: "input",
message: "What is this noobs name?",
name: "name"
},
{
type: "input",
message: "What is your id?",
name: "id"
},
{
type: "input",
message: "What is this intern's email address?",
name: "email"
},
{
type: "input",
message: "What is this intern's school?",
name: "school"
}
])
.then(({name, id, email, school}) => {
const intern = new Intern(name, id, email, school)
teamArray.push(intern)
addTeamMembers()
});
};
function addEngineer() {
inquirer.prompt([
{
type: "input",
message: "What is this engineer's name?",
name: "name"
},
{
type: "input",
message: "What is your id?",
name: "id"
},
{
type: "input",
message: "What is this engineer's email address?",
name: "email"
},
{
type: "input",
message: "What is this engineer's Github profile?",
name: "github"
}
])
.then(({name, id, email, github}) => {
const engineer = new Engineer(name, id, email, github)
teamArray.push(engineer)
addTeamMembers()
});
};
// function teamDone() {
// const teamArray = render(team);
// fs.writeFile(outputPath, teamArray, (err) =>
// err ? console.log(err) : console.log("Success!")
// );
// }
init();
// After the user has input all employees desired, call the `render` function (required
// above) and pass in an array containing all employee objects; the `render` function will
// generate and return a block of HTML including templated divs for each employee!