updateVersion.js 857 B

123456789101112131415161718192021222324252627282930
  1. // const fs = require('fs')
  2. // const packageJsonPath = './package.json'
  3. // // 读取package.json文件
  4. // const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))
  5. // // 获取当前版本号
  6. // const currentVersion = packageJson.version
  7. // // 自增修订版本号
  8. // const versionParts = currentVersion.split('.')
  9. // versionParts[2] = parseInt(versionParts[2], 10) + 1
  10. // // 更新package.json文件中的版本号
  11. // packageJson.version = versionParts.join('.')
  12. // // 将更新后的package.json文件写入磁盘
  13. // fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
  14. // // 输出更新后的版本号
  15. // console.log(`版本号已更新为 ${packageJson.version}`)
  16. const { exec } = require('child_process')
  17. exec("git add ./package.json", {}, (error, stdout, stderr) => {
  18. if (error) {
  19. console.log(error)
  20. }
  21. })