fix isFile bug
was previously using `fs.lstatSync().isFile()`. The `isFile()` method doesnt seem to exist so i went with `fs.existsSync()` instead.
This commit is contained in:
parent
2536c40517
commit
0f845a3218
12
lib/node.js
12
lib/node.js
@ -3,16 +3,16 @@ import fs from "fs"
|
|||||||
|
|
||||||
|
|
||||||
export const Node = {
|
export const Node = {
|
||||||
isFile:function(filename){
|
isFile: function(filename) {
|
||||||
try {
|
try {
|
||||||
return fs.lstatSync(filename).isFile()
|
return fs.existsSync(filename)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.error(err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
getFullPath:function(folderPath){
|
getFullPath: function(folderPath) {
|
||||||
return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn))
|
return fs.readdirSync(folderPath).map(fn => path.join(folderPath, fn))
|
||||||
},
|
},
|
||||||
getFiles: function(dir) {
|
getFiles: function(dir) {
|
||||||
@ -31,11 +31,11 @@ export const Node = {
|
|||||||
});
|
});
|
||||||
return results.filter(f => f.endsWith(".md"))
|
return results.filter(f => f.endsWith(".md"))
|
||||||
},
|
},
|
||||||
readFileSync:function(fullPath){
|
readFileSync: function(fullPath) {
|
||||||
return fs.readFileSync(fullPath, "utf8")
|
return fs.readFileSync(fullPath, "utf8")
|
||||||
},
|
},
|
||||||
|
|
||||||
getMarkdownFolder: function () {
|
getMarkdownFolder: function() {
|
||||||
return path.join(process.cwd(), 'posts')
|
return path.join(process.cwd(), 'posts')
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user