updateVersionScript.js 826 B

123456789101112131415161718192021222324252627
  1. var fs = require('fs');
  2. var path = require('path');
  3. function processDate () {
  4. var date = new Date();
  5. var day = date.getUTCDate();
  6. day = day > 9 ? day : '0' + day;
  7. var month = date.getMonth() + 1;
  8. month = month > 9 ? month : '0' + month;
  9. var minutes = date.getMinutes();
  10. minutes = minutes > 9 ? minutes : '0' + minutes;
  11. var hour = date.getHours();
  12. hour = hour > 9 ? hour : '0' + hour;
  13. return {
  14. year: date.getFullYear(),
  15. month: month,
  16. day: day,
  17. hour: hour,
  18. minutes: minutes
  19. }
  20. }
  21. var versionInfo = processDate();
  22. var versionString = `${versionInfo.year}_${versionInfo.month}_${versionInfo.day} ${versionInfo.hour}_${versionInfo.minutes}`;
  23. var fileData = `{ "version":"${versionString}" }`;
  24. var filePath = path.join(__dirname, '.ima_version.json');
  25. fs.writeFileSync(filePath, fileData);