fix: test prevents server loading, add logs
This commit is contained in:
parent
fd99da96af
commit
cead37051e
|
@ -1,18 +1,26 @@
|
|||
// @flow
|
||||
import debug from 'debug';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
const log = debug('services');
|
||||
const services = {};
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(file => file.indexOf('.') !== 0 && file !== path.basename(__filename))
|
||||
.filter(
|
||||
file =>
|
||||
file.indexOf('.') !== 0 &&
|
||||
file !== path.basename(__filename) &&
|
||||
!file.includes('.test')
|
||||
)
|
||||
.forEach(fileName => {
|
||||
const servicePath = path.join(__dirname, fileName);
|
||||
const name = servicePath.replace(/\.js$/, '');
|
||||
const name = path.basename(servicePath.replace(/\.js$/, ''));
|
||||
// $FlowIssue
|
||||
const Service = require(servicePath).default;
|
||||
services[name] = new Service();
|
||||
log(`loaded ${name} service`);
|
||||
});
|
||||
|
||||
export default services;
|
||||
|
|
Reference in New Issue