From 1205e99d629b193e41c99f32a203e3b8e11dee49 Mon Sep 17 00:00:00 2001 From: axetroy Date: Tue, 10 Oct 2017 00:30:39 +0800 Subject: [PATCH] update --- app/app.js | 15 +++++++++------ app/provider.js | 2 ++ index.js | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/app.js b/app/app.js index 624618b..0e69f92 100644 --- a/app/app.js +++ b/app/app.js @@ -94,14 +94,17 @@ class App { console.log(dialog.message()); await dialog.dismiss(); }); - const providers = this.providers; + const entities = this.providers + .map(Provider => new Provider()) + .filter(entity => entity.active === true); - while (providers.length) { - const Provider = providers.shift(); - this.entities.push(new Provider()); - } + const aloneEntity = entities.find(entity => entity.alone); - console.info(`Bootstrap done!`); + if (aloneEntity && !this.options.isProduction) { + this.entities = [aloneEntity]; + } else { + this.entities = entities; + } if (this.options.once === true) { await this.run(); diff --git a/app/provider.js b/app/provider.js index 44afe30..162a5cf 100644 --- a/app/provider.js +++ b/app/provider.js @@ -1,6 +1,8 @@ class Provider { constructor(name) { this.name = name; + this.active = true; + this.alone = false; } async resolve(phone) {} } diff --git a/index.js b/index.js index 6935141..4ec2aab 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const App = require('./app/app'); const isProduction = process.env.NODE_ENV === 'production'; new App({ + isProduction, username: 'abc123mmp', name: '张大爷', password: 'abc123abc123',