UNPKG

jjz-deploy

Version:

基于NodeJS的前端部署工具,将前端打包好的目录进行压缩、上传到服务器、备份并且解压到服务器目录

28 lines (22 loc) 674 B
exports.formatDate = function (date = new Date, format = 'yyyy-MM-dd HH:mm') { const o = { 'M+': '00' + (date.getMonth() + 1), 'd+': '00' + date.getDate(), 'H+': '00' + date.getHours(), 'm+': '00' + date.getMinutes(), 's+': '00' + date.getSeconds() }; function match (fmt, exp, val) { const matcher = fmt.match(exp); if (matcher) { const matchVal = matcher[ 0 ]; return fmt.replace(matchVal, val.substring(val.length - matchVal.length)); } return fmt; } format = match(format, /y+/, '' + date.getFullYear()); for (const key in o) { format = match(format, new RegExp(key), o[ key ]); } return format; }