提交 959134f9 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

get rid of global config DEFAULT_PUPPET_PORT

上级 db17bab1
......@@ -8,7 +8,6 @@
"DEFAULT_PUPPET": "web",
"DEFAULT_PROFILE": "profile",
"DEFAULT_PORT": 8788,
"DEFAULT_PUPPET_PORT": 18788,
"DEFAULT_PROTOCOL": "io|0.0.1",
"DEFAULT_TOKEN": "WECHATY_IO_TOKEN",
"DEFAULT_APIHOST": "api.wechaty.io",
......
......@@ -16,7 +16,6 @@ test('Config list vars', t => {
t.truthy(Config.DEFAULT_PORT , 'should export DEFAULT_PORT')
t.truthy(Config.DEFAULT_PROFILE , 'should export DEFAULT_PROFILE')
t.truthy(Config.DEFAULT_HEAD , 'should export DEFAULT_HEAD')
t.truthy(Config.DEFAULT_PUPPET_PORT , 'should export DEFAULT_PUPPET_PORT')
t.truthy(Config.DEFAULT_PROTOCOL , 'should export DEFAULT_PROTOCOL')
t.truthy(Config.DEFAULT_APIHOST , 'should export DEFAULT_APIHOST')
t.truthy(Config.CMD_CHROMIUM , 'should export CMD_CHROMIUM')
......
......@@ -36,6 +36,8 @@ const Watchdog = require('./watchdog')
const UtilLib = require('../util-lib')
const Config = require('../config')
const DEFAULT_PUPPET_PORT = 18788 // // W(87) X(88), ascii char code ;-]
class PuppetWeb extends Puppet {
constructor({
head = Config.head
......@@ -62,7 +64,7 @@ class PuppetWeb extends Puppet {
return co.call(this, function* () {
this.port = yield UtilLib.getPort(Config.DEFAULT_PUPPET_PORT)
this.port = yield UtilLib.getPort(DEFAULT_PUPPET_PORT)
log.verbose('PuppetWeb', 'init() getPort %d', this.port)
yield this.initAttach(this)
......
......@@ -23,9 +23,14 @@ const EventEmitter = require('events')
class Server extends EventEmitter {
constructor({
port = Config.DEFAULT_PUPPET_PORT // W(87) X(88), ascii char code ;-]
} = {}) {
port
}) {
super()
if (!port) {
throw new Error('port not found')
}
this.port = port
}
......
......@@ -26,5 +26,4 @@ test('Wechaty Config setting', t => {
t.truthy(Config.DEFAULT_HEAD , 'should has DEFAULT_HEAD')
t.truthy(Config.DEFAULT_PUPPET , 'should has DEFAULT_PUPPET')
t.truthy(Config.DEFAULT_PORT , 'should has DEFAULT_PORT')
t.truthy(Config.DEFAULT_PUPPET_PORT, 'should has DEFAULT_PUPPET_PORT')
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册