forked from CSS-Tricks/coding-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
take_screenshots.js
39 lines (31 loc) · 860 Bytes
/
take_screenshots.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
const argv = require("minimist")(process.argv.slice(2));
const puppeteer = require("puppeteer");
const fs = require('fs');
// Check that the font directory exists
// and create it, if not.
let dir = `screenshots/${argv.font}`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
(async () => {
const browser = await puppeteer.launch({
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
const page = await browser.newPage();
// Make High Res
await page.setViewport({
width: 800,
height: 600,
deviceScaleFactor: 2
});
await page.goto(
`http://localhost:5000/samples/${argv.lang}?font=${argv.font}&theme=${argv.theme}`, {
waitUntil: "networkidle0",
timeout: 60000
}
);
await page.screenshot({
path: `screenshots/${argv.font}/${argv.lang}-${argv.theme}.png`,
});
await browser.close();
})();