🧑💻 Add simple filesystem file provider
- Allows parsing files from a local folder
This commit is contained in:
24
server/parser/filesystem.js
Normal file
24
server/parser/filesystem.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user