diff --git a/package.json b/package.json index d0decd6591d9e90eb987f0e204084338a06c96a5..509fcb97e179c834d241c50befac7805db876c33 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "description": "Wechaty is a Bot SDK for Individual Account, Powered by TypeScript, Docker, and 💖", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", + "engines": { + "node": ">= 12" + }, "wechaty": { "DEFAULT_PORT": 8080, "DEFAULT_PROTOCOL": "io|0.0.1", @@ -79,9 +82,6 @@ "url": "https://opencollective.com/wechaty" }, "homepage": "https://github.com/wechaty/", - "engines": { - "node": ">= 12" - }, "dependencies": { "brolog": "^1.8.3", "clone-class": "^0.7.3", diff --git a/src/wechaty.ts b/src/wechaty.ts index 2f4650a573f17273691862b7bca3ea60620821ab..7361a21dab0c2052fc46094fba37075a26cd9a8e 100644 --- a/src/wechaty.ts +++ b/src/wechaty.ts @@ -240,9 +240,10 @@ export class Wechaty extends EventEmitter implements Sayable { * bot.use(WechatyReportPlugin({ url: 'http://somewhere.to.report.your.data.com' }) */ public static use ( - ...plugins: WechatyPlugin[] + ...plugins: (WechatyPlugin | WechatyPlugin[])[] ) { - this.globalPluginList = this.globalPluginList.concat(plugins) + const pluginList = plugins.flat() + this.globalPluginList = this.globalPluginList.concat(pluginList) } /** @@ -589,8 +590,9 @@ export class Wechaty extends EventEmitter implements Sayable { * // The same usage with Wechaty.use(). * */ - public use (...plugins: WechatyPlugin[]) { - plugins.forEach(plugin => plugin(this)) + public use (...plugins: (WechatyPlugin | WechatyPlugin[])[]) { + const pluginList = plugins.flat() + pluginList.forEach(plugin => plugin(this)) return this }