Skip to content

Commit

Permalink
fix(processor): add race condition warning
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Oct 2, 2021
1 parent e4e15b8 commit 2a6cbda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/plugins/processor/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Promise = require('bluebird');
const { parse: yfm } = require('hexo-front-matter');
const { extname, relative } = require('path');
const { Pattern } = require('hexo-util');
const { magenta } = require('nanocolors');

module.exports = ctx => {
return {
Expand Down Expand Up @@ -97,6 +98,9 @@ function processPage(ctx, file) {
}

if (doc) {
if (file.type !== 'update') {
ctx.log.warn(`Trying to "create" ${magenta(file.path)}, but the file already exists!`);
}
return doc.replace(data);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/plugins/processor/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { parse: yfm } = require('hexo-front-matter');
const { extname, join } = require('path');
const { stat, listDir } = require('hexo-fs');
const { slugize, Pattern, Permalink } = require('hexo-util');
const { magenta } = require('nanocolors');

const postDir = '_posts/';
const draftDir = '_drafts/';
Expand Down Expand Up @@ -164,6 +165,9 @@ function processPost(ctx, file) {
}

if (doc) {
if (file.type !== 'update') {
ctx.log.warn(`Trying to "create" ${magenta(file.path)}, but the file already exists!`);
}
return doc.replace(data);
}

Expand Down

0 comments on commit 2a6cbda

Please sign in to comment.