diff --git a/fuse.js b/fuse.js index a50cf787..343ae99f 100644 --- a/fuse.js +++ b/fuse.js @@ -9,7 +9,7 @@ const _ = require('lodash') const Promise = require('bluebird') const colors = require('colors/safe') -const fs = Promise.promisifyAll(require('fs')) +const fs = Promise.promisifyAll(require('fs-extra')) const fsbx = require('fuse-box') const nodemon = require('nodemon') const path = require('path') @@ -71,11 +71,13 @@ console.info(colors.white('└── ') + colors.green('Running global tasks...' let globalTasks = Promise.mapSeries([ () => { console.info(colors.white(' └── ') + colors.green('Copy + Minify ACE modes to assets...')) - return fs.readdirAsync('./node_modules/brace/mode').then(modeList => { - return Promise.map(modeList, mdFile => { - console.info(colors.white(' mode-' + mdFile)) - let result = uglify.minify(path.join('./node_modules/brace/mode', mdFile), { output: { 'max_line_len': 1000000 } }) - return fs.writeFileAsync(path.join('./assets/js/ace', 'mode-' + mdFile), result.code) + return fs.ensureDirAsync('./assets/js/ace').then(() => { + return fs.readdirAsync('./node_modules/brace/mode').then(modeList => { + return Promise.map(modeList, mdFile => { + console.info(colors.white(' mode-' + mdFile)) + let result = uglify.minify(path.join('./node_modules/brace/mode', mdFile), { output: { 'max_line_len': 1000000 } }) + return fs.writeFileAsync(path.join('./assets/js/ace', 'mode-' + mdFile), result.code) + }) }) }) } diff --git a/libs/entries.js b/libs/entries.js index 00447190..8c09e95e 100644 --- a/libs/entries.js +++ b/libs/entries.js @@ -285,6 +285,9 @@ module.exports = { includeMarkdown: true, includeParentInfo: true, cache: true + }).catch(err => { + winston.error(err) + return err }).then((pageData) => { return { entryPath, @@ -292,6 +295,9 @@ module.exports = { parent: pageData.parent || {}, text: mark.removeMarkdown(pageData.markdown) } + }).catch(err => { + winston.error(err) + return err }).then((content) => { return db.Entry.findOneAndUpdate({ _id: content.entryPath @@ -304,6 +310,9 @@ module.exports = { new: true, upsert: true }) + }).catch(err => { + winston.error(err) + return err }) }, diff --git a/libs/markdown.js b/libs/markdown.js index 9ceec7ee..6e66f9c8 100644 --- a/libs/markdown.js +++ b/libs/markdown.js @@ -173,6 +173,10 @@ const parseContent = (content) => { let output = mkdown.render(content) let cr = cheerio.load(output) + if (cr.root().children().length < 1) { + return '' + } + // -> Check for empty first element let firstElm = cr.root().children().first()[0]