import path from 'path' import fs from "fs" export class Node { static isFile = (filename) => { try { return fs.existsSync(filename) } catch (err) { console.error(err) return false } } static getFullPath = (folderPath) => { return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn)) } static getFiles = (dir) => { var results = []; var list = fs.readdirSync(dir); list.forEach(function(file) { file = dir + '/' + file; var stat = fs.statSync(file); if (stat && stat.isDirectory()) { /* Recurse into a subdirectory */ results = results.concat(Node.getFiles(file)); } else { /* Is a file */ results.push(file); } }); return results.filter(f => f.endsWith(".md")) } static readFileSync = (fullPath) => { return fs.readFileSync(fullPath, "utf8") } static getMarkdownFolder = () => { const notesDir = path.join(process.cwd(), 'notes') if (!Node.isFile(notesDir)) { console.warn("Notes Directory does not seem to exist: ", notesDir) } return notesDir } }