forked from sindresorhus/electron-dl
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.js
More file actions
28 lines (20 loc) · 710 Bytes
/
run.js
File metadata and controls
28 lines (20 loc) · 710 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
'use strict';
const electron = require('electron');
const minimist = require('minimist');
const samples = require('./lib/samples');
const server = require('./lib/server');
require('.')();
const argv = minimist(process.argv.slice(2));
electron.app.on('ready', async () => {
server();
const win = new electron.BrowserWindow();
win.on('closed', samples.teardown);
win.webContents.session.enableNetworkEmulation({
latency: 2,
downloadThroughput: 1024 * 1024
});
const numSampleFiles = 'files' in argv ? argv.files : 5;
const files = await samples.setup(numSampleFiles);
win.loadURL(`http://localhost:8080/index.html?files=${JSON.stringify(files)}`);
});
process.on('SIGINT', samples.teardown);