From 3f45e26755f8b1fc0fa3d43af5b4776d57e01232 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Wed, 30 Aug 2017 05:18:28 -0500 Subject: [PATCH] -whitespace --- lib/models/post.js | 10 +++++----- lib/plugins/processor/post.js | 2 +- test/scripts/models/post.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/models/post.js b/lib/models/post.js index a34df832a3..40304309cd 100644 --- a/lib/models/post.js +++ b/lib/models/post.js @@ -139,7 +139,7 @@ module.exports = function(ctx) { ).map(cat => Array.isArray(cat) ? removeEmptyTag(cat) : cat + '' ); - + var PostCategory = ctx.model('PostCategory'); var Category = ctx.model('Category'); var id = this._id; @@ -159,24 +159,24 @@ module.exports = function(ctx) { name: cat, parent: i ? parentIds[i - 1] : {$exists: false} }, {lean: true}); - + if (data) { allIds.push(data._id); parentIds.push(data._id); return data; } - + // Insert the category if not exist var obj = {name: cat}; if (i) obj.parent = parentIds[i - 1]; - + return Category.insert(obj).catch(err => { // Try to find the category again. Throw the error if not found var data = Category.findOne({ name: cat, parent: i ? parentIds[i - 1] : {$exists: false} }, {lean: true}); - + if (data) return data; throw err; }).then(data => { diff --git a/lib/plugins/processor/post.js b/lib/plugins/processor/post.js index 4cc57789e5..399ed1a7de 100644 --- a/lib/plugins/processor/post.js +++ b/lib/plugins/processor/post.js @@ -53,7 +53,7 @@ module.exports = function(ctx) { var info = parseFilename(config.new_post_name, path); var keys = Object.keys(info); var key; - + data.source = file.path; data.raw = content; data.slug = info.title; diff --git a/test/scripts/models/post.js b/test/scripts/models/post.js index 19b3c10cbe..69821fc046 100644 --- a/test/scripts/models/post.js +++ b/test/scripts/models/post.js @@ -127,7 +127,7 @@ describe('Post', () => { }).then(post => post.setCategories(['foo', 'bar', 'baz']) .thenReturn(Post.findById(post._id))).then(post => { var cats = post.categories; - + // Make sure the order of categories is correct cats.map((cat, i) => { // Make sure the parent reference is correct @@ -326,11 +326,11 @@ describe('Post', () => { // Category 1 should be foo, no parent cats[0].name.should.eql('foo'); should.not.exist(cats[0].parent); - + // Category 2 should be bar, foo as parent cats[1].name.should.eql('bar'); cats[1].parent.should.eql(cats[0]._id); - + // Category 3 should be baz, no parent cats[2].name.should.eql('baz'); should.not.exist(cats[2].parent);