forked from plollaton/electron-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
35 lines (26 loc) · 824 Bytes
/
run.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
'use strict';
const electron = require('electron');
const minimist = require('minimist');
const samples = require('./lib/samples.js');
const server = require('./lib/server.js');
const electronDl = require('.');
electronDl();
const argv = minimist(process.argv.slice(2));
(async () => {
await electron.app.whenReady();
server();
const win = new electron.BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
win.on('closed', samples.teardown);
win.webContents.session.enableNetworkEmulation({
latency: 2,
downloadThroughput: 1024 * 1024
});
const numberSampleFiles = 'files' in argv ? argv.files : 5;
const files = await samples.setup(numberSampleFiles);
await win.loadURL(`http://localhost:8080/index.html?files=${JSON.stringify(files)}`);
})();
process.on('SIGINT', samples.teardown);