From 0f845a3218b5c8a6c66ce8b8bbc94fd0c5794764 Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sat, 23 Dec 2023 20:12:31 -0600 Subject: [PATCH] fix isFile bug was previously using `fs.lstatSync().isFile()`. The `isFile()` method doesnt seem to exist so i went with `fs.existsSync()` instead. --- lib/node.js | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/node.js b/lib/node.js index 60fe6f3..e11724d 100644 --- a/lib/node.js +++ b/lib/node.js @@ -3,39 +3,39 @@ import fs from "fs" export const Node = { - isFile:function(filename){ - try { - return fs.lstatSync(filename).isFile() - } catch (err) { - console.log(err) - return false - } - - }, - getFullPath:function(folderPath){ - return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn)) - }, - getFiles: function(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")) - }, - readFileSync:function(fullPath){ - return fs.readFileSync(fullPath, "utf8") - }, - - getMarkdownFolder: function () { - return path.join(process.cwd(), 'posts') + isFile: function(filename) { + try { + return fs.existsSync(filename) + } catch (err) { + console.error(err) + return false } -} \ No newline at end of file + + }, + getFullPath: function(folderPath) { + return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn)) + }, + getFiles: function(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")) + }, + readFileSync: function(fullPath) { + return fs.readFileSync(fullPath, "utf8") + }, + + getMarkdownFolder: function() { + return path.join(process.cwd(), 'posts') + } +}