Skip to content

Commit

Permalink
feat: 暴露 generateSchema、 generateData、 startServer 出去,方便三方直接调用内部方法。
Browse files Browse the repository at this point in the history
  • Loading branch information
limengke123 committed Jul 4, 2019
1 parent 00abd8b commit f176381
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defaultOption: option = {

export type optionTuple = [option, any]

export const mock = function (option: option): void {
const mock = function (option: option): void {
Promise.resolve({...defaultOption, ...option})
// 1. 加载本地的 config 文件
.then(loadConfig)
Expand All @@ -33,4 +33,12 @@ export const mock = function (option: option): void {
})
}

export {
mock,
loadConfig,
generateData,
generateSchema,
startServer
}

export default mock
2 changes: 1 addition & 1 deletion src/tasks/generateSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SCHEMA_FILE = './schema.json'
const ERROR_PATH = '2. 生成 schema.json: '


export function generateSchema ([option]: optionTuple) {
export function generateSchema ([option]: optionTuple): Promise<optionTuple> {
const { swaggerPath, schemaPath } = option
const SCHEMA_FILE_PATH = path.resolve(schemaPath as string, SCHEMA_FILE)
return accessFile(SCHEMA_FILE_PATH)
Expand Down

0 comments on commit f176381

Please sign in to comment.