-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
49 lines (38 loc) · 1.27 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
48
49
//#region Imports
// Library ----------------------------------------------------------------------------------
import { Logger } from './lib/logger';
import { FilePaths } from './lib/file-paths.js';
import { PuppeteerWrapper } from './lib/puppeteer-wrapper';
//#endregion
//#region Setup - Dependency Injection-----------------------------------------------
const _logger = new Logger();
const _filePaths = new FilePaths(_logger, "puppeteer-electron-quickstart");
const _puppeteerWrapper = new PuppeteerWrapper(_logger, _filePaths,
{ headless: false, width:1920, height: 1080 });
//#endregion
//#region Main ----------------------------------------------------------------------
async function main() {
/* main code
...
const page = await _puppeteerWrapper.newPage();
await page.goto('https:/www.google.com');
...
*/
}
(async () => {
try {
const chromeSet = await _puppeteerWrapper.setup();
if (!chromeSet) {
return;
}
await main();
} catch(e) {
_logger.logError('Thrown error:');
_logger.logError(e);
} finally {
await _puppeteerWrapper.cleanup();
}
_logger.logInfo('Done. Close window to exit');
await _logger.exportLogs(_filePaths.logsPath());
})();
//#endregion