Skip to content

Commit

Permalink
fs variable declaration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalpanchal committed Jun 25, 2019
1 parent 4a62459 commit 7d3501a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/resources/fs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const fs = require('fs')
module.exports = {
get(from, size) {
const rootPath = __dirname.split('/lib/resources/fs')[0]
const contentPath = _.get(environment(), 'source.config.contentPath')
if(!contentPath) reject('Could not read content directory.')
if(contentPath[0] !== '/') contentPath = '/' + contentPath
let contentPath = _.get(environment(), 'source.config.contentPath')
if (!contentPath) reject('Could not read content directory.')
if (contentPath[0] !== '/') contentPath = '/' + contentPath
return new Promise((resolve, reject) => {
let blogs = []
fs.readdir(rootPath + contentPath, async (err, files) => {
if(err) reject('Could not read content directory.')
for(let i = 0; i < files.length; i++) {
if (err) reject('Could not read content directory.')
for (let i = 0; i < files.length; i++) {
let f = files[i]
blogs.push(await new Promise(res => fs.readFile(rootPath + contentPath + '/' + f, 'utf-8', (err, content) => {
if(err) reject('Could not read file.', err)
if (err) reject('Could not read file.', err)
let blog = {}
blog.title = f.split('.')[0]
blog.content = f.split('.')[1] === 'md' ? markdown.toHTML(content) : content
Expand Down

0 comments on commit 7d3501a

Please sign in to comment.