-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (50 loc) · 1.56 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
const inquirer = require('inquirer');
const fs = require('fs');
const {Triangle, Circle, Square} = require('./lib/shapes.js');
function init() {
inquirer.prompt([
{
type: "input",
message: "Choose the letters for your SVG (Up to 3).",
name: "letters"
},
{
type: "input",
message: "Choose a text color (Color keyword or hexadecimal in #XXXXXX format).",
name: "textColor"
},
{
type: "list",
message: "Choose a shape for your SVG.",
name: "shape",
choices: ['Circle', 'Triangle', 'Square']
},
{
type: "input",
message: "Choose a shape color (Color keyword or hexadecimal in #XXXXXX format).",
name: "shapeColor"
}
])
.then((answers) => {
let mySVG;
switch(answers.shape) {
case 'Triangle':
mySVG = new Triangle(answers.letters, answers.textColor, answers.shapeColor);
break;
case 'Circle':
mySVG = new Circle(answers.letters, answers.textColor, answers.shapeColor);
break;
case 'Square':
mySVG = new Square(answers.letters, answers.textColor, answers.shapeColor);
break;
}
fs.writeFile('./examples/example.svg', mySVG.generateShape(), (err) =>
err
? console.error(err)
: console.log(
`Your svg has been generated!`
)
)
})
}
init();