Comparing version 1.6.1 to 1.6.3
@@ -11,3 +11,9 @@ 'use strict'; | ||
const { apiDir = '', enable } = appConfig || {}; | ||
const mockPathList = getAllMockPathList(apiDir); | ||
let mockPathList = []; | ||
if (enable) { | ||
mockPathList = getAllMockPathList(apiDir); | ||
} | ||
return function* leafMiddleware(next) { | ||
@@ -114,12 +120,17 @@ if (!enable) return yield next; | ||
let results = []; | ||
const fileNameOrDirName = fs.readdirSync(dir); | ||
fileNameOrDirName.forEach(function(file) { | ||
const fileDir = dir + '/' + file; | ||
const stat = fs.statSync(fileDir); | ||
if (stat && stat.isDirectory()) { | ||
results = results.concat(getMockPath(fileDir)); | ||
} else { | ||
results.push(fileDir.replace(mockFilePath, '').replace(/\..+\..+$/, '')); | ||
} | ||
}); | ||
try { | ||
const fileNameOrDirName = fs.readdirSync(dir); | ||
fileNameOrDirName.forEach(function(file) { | ||
const fileDir = dir + '/' + file; | ||
const stat = fs.statSync(fileDir); | ||
if (stat && stat.isDirectory()) { | ||
results = results.concat(getMockPath(fileDir)); | ||
} else { | ||
results.push(fileDir.replace(mockFilePath, '').replace(/\..+\..+$/, '')); | ||
} | ||
}); | ||
} catch (e) { | ||
console.error(chalk.red(`==========目录不存在===========\n${dir}`)); | ||
} | ||
return results; | ||
@@ -126,0 +137,0 @@ }(mockFilePath)); |
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="1.6.3"></a> | ||
## [1.6.3](https://github.com/forsigner/egg-leaf/compare/v1.6.2...v1.6.3) (2018-04-13) | ||
<a name="1.6.2"></a> | ||
## [1.6.2](https://github.com/forsigner/egg-leaf/compare/v1.6.1...v1.6.2) (2018-04-13) | ||
### Bug Fixes | ||
* 修复当配置文件为配置目录时,或者配置目录错误时,应用报错的bug ([8f86ed0](https://github.com/forsigner/egg-leaf/commit/8f86ed0)) | ||
<a name="1.6.1"></a> | ||
@@ -7,0 +22,0 @@ ## [1.6.1](https://github.com/forsigner/egg-leaf/compare/v1.6.0...v1.6.1) (2018-04-11) |
{ | ||
"name": "egg-leaf", | ||
"version": "1.6.1", | ||
"version": "1.6.3", | ||
"description": "Mock server for egg", | ||
@@ -5,0 +5,0 @@ "eggPlugin": { |
@@ -22,3 +22,3 @@ # egg-leaf | ||
exports.leaf = { | ||
apiDir: 'config/api-docs', // 接口文档目录 | ||
apiDir: api-docs1, // 接口文档目录 | ||
enable: true, // 是否开启 mock 服务 | ||
@@ -25,0 +25,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10306
197