Commit 4b7ae2f 1 parent dcab51e commit 4b7ae2f Copy full SHA for 4b7ae2f
File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ const fs = require('fs')
3
3
const winston = require ( 'winston' )
4
4
const chalk = require ( 'chalk' )
5
5
const path = require ( 'path' )
6
-
7
- function readDir ( dir ) {
8
- const files = fs . readdirSync ( dir )
6
+ const { promisify } = require ( 'util' )
7
+ async function readDir ( dir ) {
8
+ const files = await promisify ( fs . readdir ) ( dir )
9
9
if ( files . length <= 0 ) return
10
10
const map = { }
11
11
for ( const file of files ) {
@@ -14,9 +14,9 @@ function readDir(dir) {
14
14
continue
15
15
}
16
16
const filePath = path . join ( dir , file )
17
- const stat = fs . statSync ( filePath )
17
+ const stat = await promisify ( fs . stat ) ( filePath )
18
18
if ( stat . isDirectory ( ) ) {
19
- const subDirMaps = readDir ( filePath )
19
+ const subDirMaps = await readDir ( filePath )
20
20
if ( subDirMaps ) {
21
21
map [ file ] = map [ file ]
22
22
? Object . assign ( map [ file ] , subDirMaps )
@@ -70,7 +70,7 @@ class controllers {
70
70
async load ( ) {
71
71
try {
72
72
// Load Controller
73
- const controllers = genControllersMap ( )
73
+ const controllers = await genControllersMap ( )
74
74
return controllers
75
75
} catch ( e ) {
76
76
winston . error ( chalk . red ( e ) )
You can’t perform that action at this time.
0 commit comments