|
@ -1,7 +1,7 @@ |
|
|
/** 定义模块和变量**/ |
|
|
/** 定义模块和变量**/ |
|
|
const execSync = require('child_process').execSync // 同步子进程
|
|
|
const execSync = require('child_process').execSync // 同步子进程
|
|
|
const fs = require('fs') // 文件读取模块
|
|
|
const fs = require('fs') // 文件读取模块
|
|
|
const versionPath = 'version.log.js' // version路径
|
|
|
|
|
|
|
|
|
const versionPath = 'public/version.log.js' // version路径
|
|
|
const buildPath = 'dist' // 打包的路径
|
|
|
const buildPath = 'dist' // 打包的路径
|
|
|
const autoPush = false // 写入版本信息之后是否自动提交git上
|
|
|
const autoPush = false // 写入版本信息之后是否自动提交git上
|
|
|
const commit = execSync('git show -s --format=%H').toString().trim() // 当前提交的版本号
|
|
|
const commit = execSync('git show -s --format=%H').toString().trim() // 当前提交的版本号
|
|
@ -32,7 +32,7 @@ if (autoPush) { |
|
|
|
|
|
|
|
|
// 将version文件移植到打包文件中
|
|
|
// 将version文件移植到打包文件中
|
|
|
if (fs.existsSync(buildPath)) { |
|
|
if (fs.existsSync(buildPath)) { |
|
|
fs.writeFileSync(`${buildPath}/${versionPath}`, fs.readFileSync(versionPath)) |
|
|
|
|
|
|
|
|
fs.writeFileSync(`${buildPath}/version.log.js`, fs.readFileSync(versionPath)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 程序执行结束
|
|
|
// 程序执行结束
|
|
|