Files
Timetable-V2/server/parser/filesystem.js
minie4 7705a299a0 🧑‍💻 Add simple filesystem file provider
- Allows parsing files from a local folder
2023-08-27 18:01:28 +02:00

25 lines
553 B
JavaScript

import fs from "fs";
/*
This file provider allows the application to use a local folder containing
parsable (.html) files, instead of downloading them from the internet.
This can be especially useful for development.
*/
export class FileSystemClient {
constructor(path) {
this.path = path;
}
getFiles() {
const contents = [];
const files = fs.readdirSync(this.path);
for (const file of files) {
const data = fs.readFileSync(this.path + "/" + file).toString();
contents.push(data);
}
return contents;
}
}