-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (39 loc) · 1.15 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
const Mustache = require('mustache');
const fs = require('fs');
const puppeteerService = require('./services/puppeteer.service');
const TEMPLATE_FILE = './README.template.md';
let DATA = {
refreshTime: new Date().toLocaleString('en-US', {
weekday: 'long',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
timeZoneName: 'short',
timeZone: 'Asia/Kolkata',
})
}
async function setInstagramPosts() {
const instagramImages = await puppeteerService.getLatestInstagramPostsFromAccount('nanhaajaan', 8);
DATA.img1 = instagramImages[0];
DATA.img2 = instagramImages[1];
DATA.img3 = instagramImages[2];
DATA.img4 = instagramImages[3];
DATA.img5 = instagramImages[4];
DATA.img6 = instagramImages[5];
DATA.img7 = instagramImages[6];
DATA.img8 = instagramImages[7];
}
async function generateReadMe() {
await fs.readFile(TEMPLATE_FILE, (err, data) => {
if (err) throw err;
const output = Mustache.render(data.toString(), DATA);
fs.writeFileSync('README.md', output);
});
}
async function action() {
await setInstagramPosts();
await generateReadMe();
await puppeteerService.close();
}
action();