convert node to static class
This commit is contained in:
parent
84c657cffa
commit
fd45def1bf
26
lib/node.js
26
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)
|
||||
|
Loading…
Reference in New Issue
Block a user