|
@@ -1,16 +1,17 @@
|
|
|
'use strict'
|
|
|
const path = require('path')
|
|
|
|
|
|
-// 获取git版本信息
|
|
|
+/******** 获取git版本信息 ********/
|
|
|
const fs = require("fs")
|
|
|
-const gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim()
|
|
|
-const ref = gitHEAD.split(': ')[1]
|
|
|
-const develop = gitHEAD.split('/')[2]
|
|
|
-const gitVersion = fs.readFileSync('.git/' + ref, 'utf-8').trim()
|
|
|
-const buildEdition = develop + ': ' + gitVersion
|
|
|
+let getFile = fs.existsSync('.git/HEAD')
|
|
|
+const gitHEAD = getFile?fs.readFileSync('.git/HEAD', 'utf-8').trim():false
|
|
|
+const ref = !gitHEAD?false:gitHEAD.split(': ')[1]
|
|
|
+const develop = !gitHEAD?false:gitHEAD.split('/')[2]
|
|
|
+const gitVersion = !ref?false:fs.readFileSync('.git/' + ref, 'utf-8').trim()
|
|
|
+const buildEdition = develop&&gitVersion?develop + ': ' + gitVersion:'未配置'
|
|
|
const myDate = new Date();
|
|
|
const buildTime = myDate.getFullYear() +'-'+ (myDate.getMonth()+1) +'-'+ myDate.getDate() +' '+ myDate.getHours() +':'+ myDate.getMinutes();
|
|
|
-const buildUser = fs.readFileSync('.git/logs/HEAD', 'utf-8').match(/<(\S*)>/)[1].match(/\+(\S*)@/)[1]
|
|
|
+const buildUser = getFile?fs.readFileSync('.git/logs/HEAD', 'utf-8').match(/<(\S*)>/)[1].match(/\+(\S*)@/)[1]:'未配置'
|
|
|
|
|
|
function resolve(dir) {
|
|
|
return path.join(__dirname, dir)
|