UNPKG

bm_scaffold_async_router

Version:

本木前端脚手架-异步路由版

41 lines (29 loc) 1.24 kB
var fs = require('fs'), path = require('path'), erosConsole = require('./util').erosConsole, readConfig = require('../../../utils/readConfig'), child_process = require('child_process'), TEMPLATE_NAME = 'bmfe-weex-eros-template'; var shell = require('shelljs'); function copyFile(execString) { child_process.exec(execString, function(error) { if (error !== null) { erosConsole('更新失败: ' + error, 'red'); } else { erosConsole('更新成功!文件已覆盖,请及时diff。'.green); } }); } function updateProject(targetPath) { var projectPath = path.resolve(process.cwd(), '../'), porjectFEPath = path.resolve(process.cwd()); shell.cd(porjectFEPath).exec('cnpm install ' + TEMPLATE_NAME); var templatePath = path.join(porjectFEPath, 'node_modules', TEMPLATE_NAME); shell.chmod('-R', '777', templatePath); shell.cp('-R', path.join(templatePath, 'template', targetPath), path.join(projectPath, targetPath, '../')); shell.chmod('-R', '777', path.join(projectPath, targetPath)); erosConsole('更新成功!文件已覆盖,请及时diff。'.green); } module.exports = { updateProject: updateProject }