UNPKG

bia

Version:

a tool for download git repository

32 lines (29 loc) 825 B
const inquirer = require('inquirer') /** * 获取需要生成骨架屏的链接 */ const getSkeletonUrl = () => { return new Promise((resolve, reject) => { const question = [{ type: 'input', name: 'url', message: '请输入需要生成骨架屏的链接', validate: (_val) => { if (/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i.test(_val)) { return true } return '请输入正确的url链接' }, }] try { inquirer.prompt(question).then((answer) => { resolve(answer.url) }) } catch (err) { reject(err) } }) } module.exports = { getSkeletonUrl, }