|
|
@ -1,10 +1,9 @@ |
|
|
|
/**定义模块和变量**/ |
|
|
|
const exec = require('child_process').exec; //异步子进程
|
|
|
|
const execSync = require('child_process').execSync; //同步子进程
|
|
|
|
const fs = require('fs'); //文件读取模块
|
|
|
|
const versionPath = 'version.txt'; //version路径
|
|
|
|
const versionPath = 'version.log.js'; //version路径
|
|
|
|
const buildPath = 'dist'; //打包的路径
|
|
|
|
const autoPush = true; //写入版本信息之后是否自动提交git上
|
|
|
|
const autoPush = false; //写入版本信息之后是否自动提交git上
|
|
|
|
const commit = execSync('git show -s --format=%H').toString().trim(); //当前提交的版本号
|
|
|
|
|
|
|
|
/**程序开始**/ |
|
|
@ -22,8 +21,7 @@ if (versionStr.indexOf(commit) != -1) { |
|
|
|
let name = execSync('git show -s --format=%cn').toString().trim(); //姓名
|
|
|
|
let email = execSync('git show -s --format=%ce').toString().trim(); //邮箱
|
|
|
|
let date = new Date(execSync('git show -s --format=%cd').toString()); //日期
|
|
|
|
let message = execSync('git show -s --format=%s').toString().trim(); //说明
|
|
|
|
versionStr = `git:${commit}\n作者:${name}<${email}>\n日期:${date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()}\n说明:${message}\n${new Array(80).join('*')}\n${versionStr}`; |
|
|
|
versionStr = `console.log('git:${commit};作者:${name}<${email}>;日期:${date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()}')`; |
|
|
|
fs.writeFileSync(versionPath, versionStr); |
|
|
|
// 写入版本信息之后,自动将版本信息提交到当前分支的git上
|
|
|
|
if (autoPush) { |
|
|
|