UNPKG

@em-cli/shared

Version:

脚手架工具方法包

21 lines (20 loc) 656 B
import { promisify } from 'util'; import path from 'path'; import os from 'os'; import imageDownload from 'image-downloader'; import downloadGitRepo from 'download-git-repo'; /** * 下载github仓库 * @description 请确保下载的项目地址是 visibility 是 Public 状态 * @example download(`github:edisonLzy/em-template-lib`,dest) */ export const download = promisify(downloadGitRepo); export const downloadImg = async url => { const dest = path.resolve(os.homedir(), 'shared/download/cache/icon.png'); const result = await imageDownload.image({ url, dest: dest, extractFilename: true }); return `${result.filename}`; };