import buildDoc from './doc'

interface BuildHandler {
  doc: ()=>void,
}

async function build(type: string) {
  const buildHandler: BuildHandler = {
    doc: buildDoc, // 处理文档生成
  }
  if (Object.prototype.hasOwnProperty.call(buildHandler, type)) {
    await buildHandler[type as 'doc']()
  }
}

// 打包命令处理
async function execBuild(options: object) {
  Object.keys(options).forEach(async (type) => {
    await build(type)
  })
}

export default execBuild
