let fs = require('fs'); let { logger } = require('./logging'); function toISODateString(d) { function pad(n) { return n < 10 ? '0' + n : n } return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + 'Z' } function getBuildInfo(buildInfoPath) { try { return fs.readFileSync(buildInfoPath, "utf8"); } catch (err) { if (err.code === 'ENOENT') { return "UNKNOWN_" + toISODateString(new Date()); } else { logger.error("Unexpected Error!", err); } } } function sleep(ms) { return new Promise(resolve => { setTimeout(resolve, ms) }) } exports.toISODateString = toISODateString; exports.getBuildInfo = getBuildInfo; exports.sleep = sleep;