-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (44 loc) · 1.58 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
const fs = require("fs");
const path = require("path");
// classes
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
// utils
const {
promptManager,
promptAddTeamMembers,
promptEngineer,
promptIntern } = require("./utils/prompts.js");
const render = require("./src/page-template.js");
const OUTPUT_DIR = path.resolve(__dirname, "./output/");
const outputPath = path.join(OUTPUT_DIR, "team.html");
const teamMembers = [];
const init = async () => {
try {
const managerData = await promptManager();
const manager = new Manager(managerData.name, managerData.id, managerData.email, managerData.officeNumber);
teamMembers.push(manager);
let addMoreTeamMembers = true;
while (addMoreTeamMembers) {
const { addTeamMembers } = await promptAddTeamMembers();
if (addTeamMembers === "Engineer") {
const engineerData = await promptEngineer();
const engineer = new Engineer(engineerData.name, engineerData.id, engineerData.email, engineerData.github);
teamMembers.push(engineer);
} else if (addTeamMembers === "Intern") {
const internData = await promptIntern();
const intern = new Intern(internData.name, internData.id, internData.email, internData.school);
teamMembers.push(intern);
} else {
addMoreTeamMembers = false;
}
}
const html = render(teamMembers);
fs.writeFileSync(outputPath, html);
console.log(`Team profile generated at ./output/team.html`);
} catch (error) {
console.error(error);
}
}
init();