-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
74 lines (69 loc) · 1.61 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
#!/usr/bin/env node
const fs = require("fs");
const util = require("util");
const inquirer = require("inquirer");
const generateReadme = require("./utils/generateReadme")
const writeFileAsync = util.promisify(fs.writeFile);
function promptUser() {
return inquirer.prompt([
{
type: "input",
name: "username",
message: "Please enter your GitHub username: "
},
{
type: "input",
name: "email",
message: "Please enter your email: "
},
{
type: "input",
name: "website",
message: "Enter your website Url ( without https:// ): "
},
{
type: "input",
name: "work",
message: "I’m currently working on: "
},
{
type: "input",
name: "learn",
message: "I’m currently learning: "
},
{
type: "input",
name: "codepen",
message: "Enter your CodePen username: "
},
{
type: "input",
name: "twitter",
message: "Enter your Twitter username: "
},
{
type: "input",
name: "sof",
message: "Enter your stackoverflow username: "
},
{
type: "input",
name: "insta",
message: "Enter your Instagram username: "
}
]);
}
// Async function using util.promisify
async function init() {
try {
// Ask user questions and generate responses
const answers = await promptUser();
const generateContent = generateReadme(answers);
// Write new README.md directory
await writeFileAsync('README.md', generateContent);
console.log('?? Successfully wrote to README.md');
} catch (err) {
console.log(err);
}
}
init();