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

disable watch for production with hotImport (#907)

上级 b092b5f6
......@@ -50,7 +50,7 @@ Raven.disableConsoleAlerts()
Raven
.config(
process.env.NODE_ENV === 'production'
isProduction()
&& 'https://f6770399ee65459a82af82650231b22c:d8d11b283deb441e807079b8bb2c45cd@sentry.io/179672',
{
release: VERSION,
......@@ -233,6 +233,11 @@ export function qrcodeValueToImageUrl(qrcodeValue: string): string {
].join('')
}
export function isProduction(): boolean {
return process.env.NODE_ENV === 'production'
|| process.env.NODE_ENV === 'prod'
}
export {
log,
Raven,
......
......@@ -55,6 +55,7 @@ import {
import {
VERSION,
config,
isProduction,
log,
Raven,
Sayable,
......@@ -488,7 +489,8 @@ export class Wechaty extends Accessory implements Sayable {
private addListenerModuleFile(event: WechatyEventName, modulePath: string): void {
const absoluteFilename = callerResolve(modulePath, __filename)
log.verbose('Wechaty', 'onModulePath() hotImpor(%s)', absoluteFilename)
log.verbose('Wechaty', 'onModulePath() hotImport(%s)', absoluteFilename)
hotImport(absoluteFilename)
.then((func: Function) => super.on(event, (...args: any[]) => {
try {
......@@ -504,6 +506,11 @@ export class Wechaty extends Accessory implements Sayable {
event, modulePath, e)
this.emit('error', e)
})
if (isProduction()) {
log.silly('Wechaty', 'addListenerModuleFile() disable watch for hotImport because NODE_ENV is production.')
hotImport(absoluteFilename, false)
}
}
private addListenerFunction(event: WechatyEventName, listener: Function): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册