fdm
Version:
基于gulp的1688前端集成化工具
35 lines (32 loc) • 1.04 kB
JavaScript
var commander = require('commander');
var helper = require('../utils/helper');
var fs = require('fs');
var path = require('path');
require('colors');
var tempPath='',tempLocalPath='';
function updateTemplate(tempLocalPath) {
if (fs.existsSync(tempLocalPath)) {
helper.deleteFile(tempLocalPath);
}
helper.getFromNPM('fdm-init-'+tempPath)
.on('close', function(){
helper.copyFile(path.join('node_modules','fdm-init-'+tempPath),tempLocalPath);
});
}
module.exports = {
help: function() {
console.log();
console.log('更新模板');
console.log(' $', 'fdm update'.green, 'h5app');
console.log();
},
run: function(argv) {
commander.parse(process.argv);
commander.option('-f, --force', 'Force to process the task.');
tempPath = commander.args[0];
tempPath = tempPath.replace('fdm-init-', '');
// 获取模板本地路径
tempLocalPath = helper.getTempDir(tempPath);
updateTemplate(tempLocalPath);
}
};