-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 826 Bytes
/
index.js
File metadata and controls
32 lines (29 loc) · 826 Bytes
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
/*
1. Use the inquirer npm package to get user input.
2. Use the qr-image npm package to turn the user entered URL into a QR code image.
3. Create a txt file to save the user input using the native fs node module.
*/
import inquirer from 'inquirer';
import qr from 'qr-image';
import fs from 'fs';
inquirer.prompt([
{
type: 'input',
name: 'URL',
message: 'Please enter your URL address:',
},
])
.then((answers) => {
const url = answers.URL;
var qu_svg = qr.image(url);
qu_svg.pipe(fs.createWriteStream('qr_image.png'));
fs.writeFile('URL.txt', url, err => {
if (err) {
console.error(err);
} else {
console.log("save successfully!");
}
});
})
.catch((error) => {
});