jenkins-cli-node
Version:
Jenkins command line tool
41 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fse = require("fs-extra");
const config_1 = require("../config");
class Cache {
constructor(filename) {
this.readFile = () => {
return fse.readFileSync(this.cacheFile, "utf8");
};
this.writeToFile = () => {
return fse.writeFile(this.cacheFile, JSON.stringify(this.cacheInfo), "utf8");
};
this.cacheFile = `./${config_1.JENKINS_DIR}/${filename}`;
fse.ensureFileSync(this.cacheFile);
}
}
exports.Cache = Cache;
class LastJobCache extends Cache {
constructor() {
super("last-build-job-cache.json");
try {
this.cacheInfo = JSON.parse(this.readFile());
}
catch (_a) {
this.cacheInfo = {
name: "",
parameters: {}
};
}
}
getJob() {
return this.cacheInfo;
}
refreshJob(job) {
this.cacheInfo = job;
this.writeToFile();
}
}
exports.LastJobCache = LastJobCache;
exports.lastJobCache = new LastJobCache();
//# sourceMappingURL=cache.js.map