()
| 15 | } |
| 16 | |
| 17 | async init() { |
| 18 | if (!this.config.host) { |
| 19 | out.access('未指定加速域名,将使用默认域名:https://raw.githubusercontent.com') |
| 20 | } else if (this.config.host?.includes('cdn.jsdelivr.net')) { |
| 21 | // 如果指定了加速域名 |
| 22 | this.config.host = 'https://cdn.jsdelivr.net' |
| 23 | } |
| 24 | // 判断是否开启拓展点 |
| 25 | if (this.config.secretExt) { |
| 26 | // 如果开了就从拓展点读取 |
| 27 | this.config = await getSecretExt(this.config) |
| 28 | } else { |
| 29 | // 如果没开拓展点,就从配置文件/环境变量中读取 |
| 30 | this.config = { |
| 31 | ...this.config, |
| 32 | token: this.config.token || process.env.GITHUB_TOKEN!, |
| 33 | } |
| 34 | } |
| 35 | if (!this.config.token || !this.config.user || !this.config.repo) { |
| 36 | out.err('缺少Github 配置信息') |
| 37 | process.exit(-1) |
| 38 | } |
| 39 | // 处理prefixKey |
| 40 | this.config.prefixKey = formattedPrefix(this.config.prefixKey) |
| 41 | this.isInit = true |
| 42 | } |
| 43 | |
| 44 | async _fetch( |
| 45 | fileName: string, |
no test coverage detected