include-me
Version:
[](https://travis-ci.com/Emre-Kul/include-me) 
31 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const file_manager_1 = require("./file-manager");
class PageController {
constructor(rootFolderPath) {
this.rootFolderPath = rootFolderPath;
this.pages = [];
}
getPages() {
return this.pages;
}
loadPagesFromFolder(path = this.rootFolderPath) {
const files = fs.readdirSync(path);
for (const file of files) {
const fileStat = fs.statSync(`${path}/${file}`);
if (fileStat.isDirectory()) {
this.loadPagesFromFolder(`${path}/${file}`);
}
else {
const fileManager = new file_manager_1.default(`${path}/${file}`);
fileManager.loadContent();
const loadedFile = fileManager.getFile();
loadedFile.path = loadedFile.path.split(this.rootFolderPath)[1];
this.pages.push(loadedFile);
}
}
}
}
exports.default = PageController;
//# sourceMappingURL=page-controller.js.map