makit
Version:
Make in JavaScript done right!
39 lines (38 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IO = void 0;
const nodefs_impl_1 = require("./fs/nodefs-impl");
const mtime_1 = require("./fs/mtime");
const db_1 = require("./db");
class IO {
static getFileSystem() {
if (!this.fs)
this.fs = new nodefs_impl_1.NodeFileSystem();
return this.fs;
}
static getMTime(db = IO.getOrCreateDataBase(), fs = this.getFileSystem()) {
if (!this.mtime)
this.mtime = new mtime_1.MTime(db, fs);
return this.mtime;
}
static getOrCreateDataBase(filepath = '.makit.db', fs = this.getFileSystem()) {
if (!this.db)
this.db = new db_1.DataBase(filepath, fs);
return this.db;
}
static clearDataBase() {
if (this.db)
this.db.clear();
}
static resetFileSystem(newFS) {
this.fs = newFS;
delete this.mtime;
delete this.db;
return {
fs: newFS,
db: this.getOrCreateDataBase(),
mtime: this.getMTime()
};
}
}
exports.IO = IO;