forked from vkarpov15/mastering-async-await
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanner.js
More file actions
30 lines (24 loc) · 911 Bytes
/
banner.js
File metadata and controls
30 lines (24 loc) · 911 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
const fs = require('fs');
const nightmare = require('nightmare');
const bannerCss = fs.readFileSync('./content/banner.css');
const banner = fs.readFileSync('./content/banner.html');
const bannerHtml = `
<link href='http://fonts.googleapis.com/css?family=Titillium+Web' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<style>
${bannerCss}
</style>
<div id="content">
${banner}
</div>
`;
fs.writeFileSync('./bin/banner.html', bannerHtml);
main().catch(error => console.error(error.stack));
async function main() {
let browser = nightmare({ show: false });
await browser.goto(`file://${__dirname}/bin/banner.html`).
viewport(800, 175).
screenshot('./bin/banner.png');
console.log('Done');
}