-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lau Skeeter
committed
May 20, 2018
1 parent
be2b64c
commit 6d67a50
Showing
13 changed files
with
456 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
ports: { | ||
test: 1234, | ||
live: 3000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
|
||
node_modules | ||
dest/* | ||
!dest/.gitexists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const app = require('./src/express.js'); | ||
const config = require('./.fantarc'); | ||
|
||
app.listen(config.ports.live, () => | ||
console.log(`Listening on port ${config.ports.live}!`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const server = require('../src/express.js'); | ||
const config = require('../.fantarc'); | ||
const puppeteer = require('puppeteer'); | ||
const path = require('path'); | ||
|
||
const outPath = path.resolve(__dirname, '..', 'dest', 'screenie.png'); | ||
|
||
const startServer = () => | ||
new Promise(rt => { | ||
server.listen( | ||
config.ports.test, | ||
rt(`http://localhost:${config.ports.test}`) | ||
); | ||
}); | ||
|
||
const takeScreenshot = async url => { | ||
const browser = await puppeteer.launch({ | ||
args: ['--no-sandbox'], | ||
ignoreHTTPSErrors: true, | ||
}); | ||
const page = await browser.newPage(); | ||
|
||
return new Promise((yay, nay) => { | ||
page.on('console', async msg => { | ||
try { | ||
const log = JSON.parse(msg.text()); | ||
if (!log.product) { | ||
throw new Error('invalid fanta'); | ||
} | ||
await page.screenshot({ path: outPath, type: 'png' }); | ||
await browser.close(); | ||
yay(log); | ||
} catch (e) { | ||
nay([e, msg]); | ||
} | ||
}); | ||
Promise.all([ | ||
page.setViewport({ width: 4400, height: 2500 }), | ||
page.goto(url), | ||
]); | ||
}); | ||
}; | ||
|
||
module.exports = () => startServer().then(url => takeScreenshot(url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const getFanta = require('./make-screenshot'); | ||
|
||
getFanta() | ||
.then(log => { | ||
console.log(log); | ||
process.exit(); | ||
}) | ||
.catch(err => { | ||
throw err; | ||
}); |
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.