Baphomet is the dedicated bot for nulloctet matrix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
888 B

  1. let fs = require('fs');
  2. let { logger } = require('./logging');
  3. function toISODateString(d) {
  4. function pad(n) { return n < 10 ? '0' + n : n }
  5. return d.getUTCFullYear() + '-'
  6. + pad(d.getUTCMonth() + 1) + '-'
  7. + pad(d.getUTCDate()) + 'T'
  8. + pad(d.getUTCHours()) + ':'
  9. + pad(d.getUTCMinutes()) + ':'
  10. + pad(d.getUTCSeconds()) + 'Z'
  11. }
  12. function getBuildInfo(buildInfoPath) {
  13. try {
  14. return fs.readFileSync(buildInfoPath, "utf8");
  15. } catch (err) {
  16. if (err.code === 'ENOENT') {
  17. return "UNKNOWN_" + toISODateString(new Date());
  18. } else {
  19. logger.error("Unexpected Error!", err);
  20. }
  21. }
  22. }
  23. function sleep(ms) {
  24. return new Promise(resolve => {
  25. setTimeout(resolve, ms)
  26. })
  27. }
  28. exports.toISODateString = toISODateString;
  29. exports.getBuildInfo = getBuildInfo;
  30. exports.sleep = sleep;