-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (45 loc) · 1.17 KB
/
index.js
File metadata and controls
53 lines (45 loc) · 1.17 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
require('dotenv').config();
const Mustache = require('mustache');
const fetch = require('node-fetch');
const fs = require('fs');
const puppeteerService = require('./services/puppeteer.service');
const MUSTACHE_MAIN_DIR = './main.mustache';
let DATA = {
refresh_date: new Date().toLocaleDateString('en-GB', {
weekday: 'long',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
timeZoneName: 'short',
timeZone: 'Europe/Stockholm',
}),
};
async function setInstagramPosts() {
const instagramImages = await puppeteerService.getLatestInstagramPostsFromAccount('visitstockholm', 3);
DATA.img1 = instagramImages[0];
DATA.img2 = instagramImages[1];
DATA.img3 = instagramImages[2];
}
async function generateReadMe() {
await fs.readFile(MUSTACHE_MAIN_DIR, (err, data) => {
if (err) throw err;
const output = Mustache.render(data.toString(), DATA);
fs.writeFileSync('README.md', output);
});
}
async function action() {
/**
* Get pictures
*/
await setInstagramPosts();
/**
* Generate README
*/
await generateReadMe();
/**
* Fermeture de la boutique 👋
*/
await puppeteerService.close();
}
action();