mirror of
https://github.com/UiO-Gaming/infoscreen3.git
synced 2026-11-06 14:24:31 +01:00
45 lines
913 B
JavaScript
45 lines
913 B
JavaScript
"use strict";
|
|
|
|
const bundle = require('./bundle.js');
|
|
let fs = require("fs");
|
|
|
|
/**
|
|
* @module infoscreen3/bundleManager
|
|
*/
|
|
class bundleManager {
|
|
|
|
constructor() {
|
|
this.bundles = {};
|
|
let dirs = getDirectories("./data");
|
|
|
|
for (let name of dirs) {
|
|
let data = getJson("./data/" + name + "/bundle.json");
|
|
let slides = getJson("./data/" + name + "/slides.json");
|
|
|
|
this.bundles[name] = new bundle(name, data, slides);
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {string} name
|
|
* @returns {bundle}
|
|
*/
|
|
getBundle(name) {
|
|
return this.bundles[name];
|
|
}
|
|
|
|
}
|
|
|
|
function getDirectories(path) {
|
|
return fs.readdirSync(path).filter(function (file) {
|
|
return fs.statSync(path + '/' + file).isDirectory();
|
|
});
|
|
}
|
|
|
|
|
|
function getJson(file) {
|
|
return JSON.parse(fs.readFileSync(file).toString());
|
|
}
|
|
|
|
module.exports = bundleManager; |