-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
81 lines (70 loc) · 2.37 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
// Packages needed for this application
const fs = require("fs");
const path = require('path');
const inquirer = require("inquirer");
const generateFile = require("./utils/generateHTML.js")
const fileName = "index.html";
const Manager = require("./utils/manager");
const Engineer = require("./utils/engineer");
const Intern = require("./utils/intern");
const buildTeamQuestion = require("./utils/addTeamQuestion");
const team = [];
let employeeRole = "Manager";
let keepBuilding = true;
async function buildTeam() {
let manager = new Manager();
console.clear();
manager.getRoleMan(employeeRole);
await manager.getName(employeeRole);
await manager.getId(employeeRole);
await manager.getEmail(employeeRole);
await manager.officeNumber();
team.push(manager);
let build = await inquirer.prompt(buildTeamQuestion);
continueBuild(build.occupation);
while (keepBuilding) {
if (employeeRole === "Engineer") {
let engineer = new Engineer();
console.clear();
engineer.getRoleEng(employeeRole);
await engineer.getName(employeeRole);
await engineer.getId(employeeRole);
await engineer.getEmail(employeeRole);
await engineer.getGithub();
team.push(engineer);
build = await inquirer.prompt(buildTeamQuestion);
continueBuild(build.occupation);
} else {
let intern = new Intern();
console.clear();
intern.getRoleInt(employeeRole);
await intern.getName(employeeRole);
await intern.getId(employeeRole);
await intern.getEmail(employeeRole);
await intern.getSchool();
team.push(intern);
build = await inquirer.prompt(buildTeamQuestion);
continueBuild(build.occupation);
}
}
writeToFile(team)
}
function continueBuild(build) {
switch (build) {
case "Finish building my team":
keepBuilding = false;
break;
case "Engineer":
employeeRole = "Engineer"
break;
case "Intern":
employeeRole = "Intern"
break;
}
}
buildTeam();
function writeToFile(team) {
fs.writeFile(path.join(__dirname, "dist", fileName), generateFile(team), err => {
err ? console.log(err) : console.log('The file has been saved!');
});
}