q-koa 7.7.7 → 7.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/app.js +14 -10
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -243,7 +243,7 @@ class APP {
|
|
|
243
243
|
// console.log(content);
|
|
244
244
|
// });
|
|
245
245
|
|
|
246
|
-
starter.on('loadAll', () => {
|
|
246
|
+
starter.on('loadAll', async () => {
|
|
247
247
|
const appName = this.config.includes[0]
|
|
248
248
|
this.server = this.app.listen(this.port, () => {
|
|
249
249
|
console.log(`server is running at http://localhost:${this.port}`)
|
|
@@ -360,7 +360,7 @@ class APP {
|
|
|
360
360
|
this.initFile(appName)
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
this.initPlugin(appName)
|
|
363
|
+
await this.initPlugin(appName)
|
|
364
364
|
this.app[appName].event = new EventEmitter()
|
|
365
365
|
|
|
366
366
|
const cacheConfig = _.get(this.app[appName], 'appConfig.cache', {
|
|
@@ -373,7 +373,7 @@ class APP {
|
|
|
373
373
|
maxAge: cacheConfig.maxAge,
|
|
374
374
|
})
|
|
375
375
|
|
|
376
|
-
this.initModel(appName)
|
|
376
|
+
await this.initModel(appName)
|
|
377
377
|
// const models = Object.keys(this.app[appName].model).join(' / ')
|
|
378
378
|
if (taskConfig.is_available) {
|
|
379
379
|
this.initTask(appName)
|
|
@@ -422,7 +422,7 @@ class APP {
|
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
initTask(appName) {
|
|
425
|
+
async initTask(appName) {
|
|
426
426
|
console.log(chalk.red(`启动任务${appName}`))
|
|
427
427
|
const taskDir = path.resolve(
|
|
428
428
|
__dirname,
|
|
@@ -431,7 +431,8 @@ class APP {
|
|
|
431
431
|
const publicExist = fs.existsSync(taskDir)
|
|
432
432
|
if (!publicExist) await fsPromise.mkdir(taskDir)
|
|
433
433
|
const list = await fsPromise.readdir(taskDir)
|
|
434
|
-
list.
|
|
434
|
+
for (let i = 0; i < list.length; i++) {
|
|
435
|
+
const folder = list[i]
|
|
435
436
|
const isFolder = fs.lstatSync(path.resolve(taskDir, folder)).isDirectory()
|
|
436
437
|
if (isFolder) {
|
|
437
438
|
const folderDir = await fsPromise.readdir(path.resolve(taskDir, folder))
|
|
@@ -450,10 +451,10 @@ class APP {
|
|
|
450
451
|
}
|
|
451
452
|
})
|
|
452
453
|
}
|
|
453
|
-
}
|
|
454
|
+
}
|
|
454
455
|
}
|
|
455
456
|
|
|
456
|
-
initPlugin(appName) {
|
|
457
|
+
async initPlugin(appName) {
|
|
457
458
|
const pluginDir = path.resolve(
|
|
458
459
|
__dirname,
|
|
459
460
|
`${rootDirectory}/${APP_DIR}/${appName}/${PLUGINS_DIR}`
|
|
@@ -461,12 +462,15 @@ class APP {
|
|
|
461
462
|
const publicExist = fs.existsSync(pluginDir)
|
|
462
463
|
if (!publicExist) await fsPromise.mkdir(pluginDir)
|
|
463
464
|
const pluginDirResult = await fsPromise.readdir(pluginDir)
|
|
464
|
-
pluginDirResult.
|
|
465
|
+
for (let i = 0; i < pluginDirResult.length; i++) {
|
|
466
|
+
const folder = pluginDirResult[i]
|
|
465
467
|
const isFolder = fs
|
|
466
468
|
.lstatSync(path.resolve(pluginDir, folder))
|
|
467
469
|
.isDirectory()
|
|
468
470
|
if (isFolder) {
|
|
469
|
-
const folderResult = await fsPromise.readdir(
|
|
471
|
+
const folderResult = await fsPromise.readdir(
|
|
472
|
+
path.resolve(pluginDir, folder)
|
|
473
|
+
)
|
|
470
474
|
folderResult.forEach((filename) => {
|
|
471
475
|
const extname = path.extname(filename)
|
|
472
476
|
if (extname === '.js') {
|
|
@@ -662,7 +666,7 @@ class APP {
|
|
|
662
666
|
}
|
|
663
667
|
})
|
|
664
668
|
}
|
|
665
|
-
}
|
|
669
|
+
}
|
|
666
670
|
}
|
|
667
671
|
|
|
668
672
|
initModel(appName) {
|