From db3955ebdcebf24d9c66d843ef5a813323403957 Mon Sep 17 00:00:00 2001 From: "Zhuohuan LI (CARPE DIEM)" Date: Mon, 31 Oct 2016 18:33:24 +0800 Subject: [PATCH] code clean --- src/config.ts | 7 +++++-- src/contact.ts | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index f0553e3c..7351e30f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -7,6 +7,7 @@ import { execSync } from 'child_process' import * as fs from 'fs' import Puppet from './puppet' +import log from './brolog-env' export type PuppetName = 'web' | 'android' | 'ios' export type HeadName = 'chrome' | 'phantomjs' | 'firefox' @@ -132,9 +133,11 @@ function isWechatyDocker() { function puppetInstance(instance?: Puppet | null): Puppet | void { if (instance !== undefined) { if (instance) { + log.verbose('Config', 'puppetInstance(%s)', instance.constructor.name) Config._puppetInstance = instance return instance } + log.verbose('Config', 'puppetInstance(null)') Config._puppetInstance = null return } @@ -142,6 +145,7 @@ function puppetInstance(instance?: Puppet | null): Puppet | void { if (!Config._puppetInstance) { throw new Error('no puppet instance') } + return Config._puppetInstance } @@ -179,6 +183,5 @@ export interface Sleepable { sleep(millisecond: number): Promise } -export * from './brolog-env' - +export { log } export default Config diff --git a/src/contact.ts b/src/contact.ts index 854d4db4..64aa7a85 100644 --- a/src/contact.ts +++ b/src/contact.ts @@ -122,8 +122,6 @@ export class Contact implements Sayable { } if (!contactGetter) { - if (!Config.puppetInstance()) { throw new Error('Config.puppetInstance() is not found by Contact') } - log.silly('Contact', 'get contact via ' + Config.puppetInstance().constructor.name) contactGetter = Config.puppetInstance() .getContact.bind(Config.puppetInstance()) -- GitLab