From b6f624eb587e4fa408a69b21a788f3667e613a54 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Wed, 8 Apr 2020 23:01:54 +0800 Subject: [PATCH] 0.20.2 for mock --- package.json | 4 ++-- src/io-client.ts | 10 +++++----- src/io.ts | 2 +- src/puppet-config.ts | 4 ++-- src/wechaty.ts | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2ae27917..6150333e 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "state-switch": "^0.9.9", "watchdog": "^0.8.17", "wechaty-puppet": "^0.24.0", - "wechaty-puppet-hostie": "^0.5.10", + "wechaty-puppet-hostie": "^0.6.1", "ws": "^7.2.3" }, "devDependencies": { @@ -133,7 +133,7 @@ "sloc": "^0.2.1", "tstest": "^0.4.10", "typedoc": "^0.16.11", - "wechaty-puppet-mock": "^0.19.0" + "wechaty-puppet-mock": "^0.20.2" }, "files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955", "files": [ diff --git a/src/io-client.ts b/src/io-client.ts index 65135663..940c6b02 100644 --- a/src/io-client.ts +++ b/src/io-client.ts @@ -58,7 +58,7 @@ export class IoClient { options.token ) - this.state = new StateSwitch('IoClient', log) + this.state = new StateSwitch('IoClient', { log }) } private async startHostie () { @@ -91,10 +91,10 @@ export class IoClient { public async start (): Promise { log.verbose('IoClient', 'start()') - if (this.state.pending()) { - log.warn('IoClient', 'start() with a pending state, not the time') - const e = new Error('state.pending() when start()') - throw e + if (this.state.on()) { + log.warn('IoClient', 'start() with a on state, wait and return') + await this.state.ready('on') + return } this.state.on('pending') diff --git a/src/io.ts b/src/io.ts index 85df4997..758a9bf5 100644 --- a/src/io.ts +++ b/src/io.ts @@ -81,7 +81,7 @@ export class Io { private eventBuffer : IoEvent[] = [] private ws : undefined | WebSocket - private readonly state = new StateSwitch('Io', log) + private readonly state = new StateSwitch('Io', { log }) private reconnectTimer? : NodeJS.Timer private reconnectTimeout? : number diff --git a/src/puppet-config.ts b/src/puppet-config.ts index f9b89ad7..4e14a8cd 100644 --- a/src/puppet-config.ts +++ b/src/puppet-config.ts @@ -12,8 +12,8 @@ export const PUPPET_DEPENDENCIES = { /** * Wechaty Internal Puppets: dependenced by package.json */ - 'wechaty-puppet-hostie' : '^0.5.10', // https://www.npmjs.com/package/wechaty-puppet-hostie - 'wechaty-puppet-mock' : '^0.19.0', // https://www.npmjs.com/package/wechaty-puppet-mock + 'wechaty-puppet-hostie' : '^0.6.1', // https://www.npmjs.com/package/wechaty-puppet-hostie + 'wechaty-puppet-mock' : '^0.20.2', // https://www.npmjs.com/package/wechaty-puppet-mock /** * Wechaty External Puppets diff --git a/src/wechaty.ts b/src/wechaty.ts index 946dd3eb..08b6eef8 100644 --- a/src/wechaty.ts +++ b/src/wechaty.ts @@ -258,8 +258,8 @@ export class Wechaty extends EventEmitter implements Sayable { this.id = cuid() - this.state = new StateSwitch('Wechaty', log) - this.readyState = new StateSwitch('WechatyReady', log) + this.state = new StateSwitch('Wechaty', { log }) + this.readyState = new StateSwitch('WechatyReady', { log }) /** * @ignore -- GitLab