dl-pig-cli
Version:
脚手架
25 lines (22 loc) • 805 B
JavaScript
const download = require('download-git-repo');
const Config = require('../config/download.config');
const File = require('../lib/File');
const { resolve } = require('path');
const getGithubTemplate = (option)=>{
return new Promise((success,error)=>{
download(`${option.url?option.url:Config.GITHUB_URL}:${Config.USER_NAME}/${option.template}#${Config.BRANCH}`,`./${option.name}`,(err)=>{
err?error(err):success(err);
})
})
}
const getLocalTemplate = (option)=>{
return new Promise((success,error)=>{
File.copyFiles(resolve(__dirname,`../template/${option.type}`,option.template),`${process.cwd()}\\${option.name}`,(data)=>{
data.status?success(data.option):error(data.err)
});
})
}
module.exports = {
getGithubTemplate,
getLocalTemplate
}