-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (48 loc) · 1.29 KB
/
index.js
File metadata and controls
57 lines (48 loc) · 1.29 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
const inquirer = require('inquirer');
const fs = require('fs');
const { Circle, Triangle, Square } = require('./lib/shapes');
const questions = [{
type: 'input',
name: 'text',
message: 'What text do you want in your shape?'
},
{
type: 'input',
name: 'text_color',
message: 'What color would you like your text to be?'
}
,
{
type: 'list',
name: 'shape',
message: 'Choose which shape you would like:',
choices: ['circle', 'triangle', 'square']
}
,
{
type: 'input',
name: 'shape_color',
message: 'What color would you like your shape?'
}
];
function init() {
inquirer.prompt(questions).then((answers) => {
let svg;
if (answers.shape === 'circle') {
svg = new Circle();
} else if (answers.shape === 'triangle') {
svg = new Triangle();
} else {
svg = new Square();
}
svg.setText(answers.text);
svg.setTextColor(answers.text_color);
svg.setShapeColor(answers.shape_color);
// GENERATE the SVG content
const svgContent = svg.render();
// WRITE the SVG content to a file and NAME IT
fs.writeFileSync('logo.svg', svgContent, 'utf-8');
console.log('Generated logo.svg successfully! Go check it out!');
});
}
init();