25 lines
553 B
JavaScript
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;
|
|
}
|
|
}
|