From 61a7e16505ccb2178f8a36b36cb09d471fd774d3 Mon Sep 17 00:00:00 2001 From: ivandevp Date: Thu, 3 Oct 2019 16:41:45 -0500 Subject: [PATCH 1/2] feat(): log error when not found snippet --- packages/@vuepress/markdown/lib/snippet.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@vuepress/markdown/lib/snippet.js b/packages/@vuepress/markdown/lib/snippet.js index 7713da90cb..72f764a92c 100644 --- a/packages/@vuepress/markdown/lib/snippet.js +++ b/packages/@vuepress/markdown/lib/snippet.js @@ -1,4 +1,4 @@ -const { fs, path } = require('@vuepress/shared-utils') +const { fs, logger, path } = require('@vuepress/shared-utils') module.exports = function snippet (md, options = {}) { const fence = md.renderer.rules.fence @@ -15,8 +15,10 @@ module.exports = function snippet (md, options = {}) { if (fs.existsSync(src)) { token.content = fs.readFileSync(src, 'utf8') } else { - token.content = 'Not found: ' + src + const errorMessage = `Not found: ${src}` + token.content = errorMessage token.info = '' + logger.error(errorMessage) } } return fence(...args) From 5f5ca2f98dfe6df5987db6b6bee000ce7d565555 Mon Sep 17 00:00:00 2001 From: ivandevp Date: Sun, 6 Oct 2019 21:24:58 -0500 Subject: [PATCH 2/2] enhance error message --- packages/@vuepress/markdown/lib/snippet.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/markdown/lib/snippet.js b/packages/@vuepress/markdown/lib/snippet.js index 72f764a92c..9ee4e726f3 100644 --- a/packages/@vuepress/markdown/lib/snippet.js +++ b/packages/@vuepress/markdown/lib/snippet.js @@ -15,10 +15,9 @@ module.exports = function snippet (md, options = {}) { if (fs.existsSync(src)) { token.content = fs.readFileSync(src, 'utf8') } else { - const errorMessage = `Not found: ${src}` - token.content = errorMessage + token.content = `Code snippet path not found: ${src}` token.info = '' - logger.error(errorMessage) + logger.error(token.content) } } return fence(...args)