UNPKG

biatest

Version:

a test tool for download git repository

40 lines (35 loc) 1.25 kB
const fs = require('fs-extra'); const path = require('path'); const downloadGitRepo = require('download-git-repo'); const ora = require('ora'); const chalk = require('chalk'); var spinner = ora('downloading bia...'); function copyTmpl(name, tmplName) { let tmplGitRepo = '', dist = path.join(process.cwd(), 'bia'); if (/^eris$/i.test(name)) { tmplGitRepo = 'gitlab:git.mail.netease.com:hzxulin/bia2eris#master' } else if (/^act$/i.test(name)) { tmplGitRepo = 'gitlab:git.mail.netease.com:hzxulin/bia2act#master' } else { console.log(chalk.yellow('param error!\n')); return; } spinner.start(); downloadGitRepo(tmplGitRepo, dist, { clone: true }, function(err) { spinner.stop(); if (!err) { if (/^act$/i.test(name)) { fs.move(path.join(process.cwd(), 'bia'), path.join(process.cwd(), ''), err => { if (err) return console.error(err) console.log(chalk.cyan('bia success!\n')); }) } else { console.log(chalk.cyan('bia success!\n')); } } else { console.log(chalk.yellow('Permission denied, bia error!\n')); } }) } module.exports = copyTmpl