Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 9, 2017
1 parent 11650ef commit 1205e99
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions app/provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class Provider {
constructor(name) {
this.name = name;
this.active = true;
this.alone = false;
}
async resolve(phone) {}
}
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const App = require('./app/app');
const isProduction = process.env.NODE_ENV === 'production';

new App({
isProduction,
username: 'abc123mmp',
name: '张大爷',
password: 'abc123abc123',
Expand Down

0 comments on commit 1205e99

Please sign in to comment.