loadSubPackage.ts 482 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3
import { ApiProtocol } from '../type'

export const LoadSubPackageProtocol: ApiProtocol = {
fxy060608's avatar
fxy060608 已提交
4 5 6
  root: {
    type: String,
    required: true,
fxy060608's avatar
fxy060608 已提交
7
    validator(value) {
fxy060608's avatar
fxy060608 已提交
8 9 10 11 12 13 14 15 16 17
      const subPackages = __uniConfig.subPackages
      if (!Array.isArray(subPackages) || subPackages.length === 0) {
        return 'no subPackages'
      }
      if (!subPackages.find(subPackage => subPackage.root === value)) {
        return 'root `' + value + '` is not found'
      }
    }
  }
}