diff --git a/lib/node.js b/lib/node.js index ecb11c9..2c93f5c 100644 --- a/lib/node.js +++ b/lib/node.js @@ -1,8 +1,9 @@ import path from 'path' import fs from "fs" -export const Node = { - isFile: function(filename) { +export class Node { + + static isFile = (filename) => { try { return fs.existsSync(filename) } catch (err) { @@ -10,11 +11,13 @@ export const Node = { return false } - }, - getFullPath: function(folderPath) { + } + + static getFullPath = (folderPath) => { return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn)) - }, - getFiles: function(dir) { + } + + static getFiles = (dir) => { var results = []; var list = fs.readdirSync(dir); list.forEach(function(file) { @@ -29,12 +32,13 @@ export const Node = { } }); return results.filter(f => f.endsWith(".md")) - }, - readFileSync: function(fullPath) { - return fs.readFileSync(fullPath, "utf8") - }, + } - getMarkdownFolder: function() { + 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)