forked from erha19/weex-debugger
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
37 lines (34 loc) · 1.2 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
const devtool = require('./lib/index');
const config = require('./lib/config');
const IP = require('ip');
const uuid = require('uuid');
/**
* Start server and lanunch chrome.
* @param {string} entry filename/floder
* @param {Object} config
* - ip ip of node server.
* - port port of node server
* - remoteDebugPort remote-debug-port of headless.
* - enableHeadless enable to start headless chromium or not.
* @param {Function} cb
*/
const startServerAndLaunchDevtool = (entry, options, cb) => {
if (options) {
config.ip = options.ip || IP.address();
config.port = options.port || 8088;
config.manual = options.manual || false;
config.CHANNELID = options.CHANNELID || options.channelId;
config.REMOTE_DEBUG_PORT = options.REMOTE_DEBUG_PORT || options.remoteDebugPort || 9222;
config.ENABLE_HEADLESS = typeof options.ENABLE_HEADLESS === 'boolean' ? options.ENABLE_HEADLESS : typeof options.enableHeadless === 'boolean' ? options.enableHeadless : true;
config.TOKEN = options.TOKEN || uuid();
}
devtool.start(entry, config, cb);
};
const api = {
startServerAndLaunchDevtool: startServerAndLaunchDevtool,
reload: devtool.reload,
refresh: devtool.refresh
};
module.exports = {
api
};