-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
43 lines (36 loc) · 1.03 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
var path = require('path');
var client = require("./client");
var NightmareBrowser = function (baseBrowserDecorator, args, config) {
const options = config.nightmareOptions || {};
const file = path.join(__dirname, 'lib/browser.js');
baseBrowserDecorator(this);
this._start = function (url) {
this._execCommand('node', [
file,
url,
JSON.stringify(options),
]);
this._process.stderr.on('data', function (data) {
console.log('' + data);
})
this._process.stdout.on('data', function (data) {
console.log('' + data);
})
this.on('kill', function (done) {
if (!this._process) return;
this._process.kill('SIGKILL');
done();
})
}
}
NightmareBrowser.prototype = {
name: 'Nightmare',
}
NightmareBrowser.$inject = ['baseBrowserDecorator', 'args', 'config']
module.exports = {
'launcher:Nightmare': ['type', NightmareBrowser],
screenshot: client.screenshot,
saveHtml: client.saveHtml,
isNightmare: client.isNightmare,
getCurrentWindow: client.getCurrentWindow,
}