From 432e6620a35b61ad58c82c1bfaff8f956030077b Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Tue, 30 Oct 2018 02:05:14 +0800 Subject: [PATCH] refactor: log error when theme cannot be resolved --- packages/@vuepress/core/lib/prepare/loadTheme.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/@vuepress/core/lib/prepare/loadTheme.js b/packages/@vuepress/core/lib/prepare/loadTheme.js index c06820f18a..3b15c118b8 100644 --- a/packages/@vuepress/core/lib/prepare/loadTheme.js +++ b/packages/@vuepress/core/lib/prepare/loadTheme.js @@ -48,8 +48,11 @@ module.exports = async function loadTheme (ctx) { themePath = localThemePath logger.tip(`\nApply theme located at ${chalk.gray(themePath)}...`) } else if (isString(theme)) { - const { entry: modulePath, name, shortcut } = themeResolver.resolve(theme, sourceDir) - + const resolved = themeResolver.resolve(theme, sourceDir) + const { entry: modulePath, name, shortcut } = resolved + if (modulePath === null) { + throw new Error(`Cannot resolve theme ${theme}.`) + } if (modulePath.endsWith('.js') || modulePath.endsWith('.vue')) { themePath = path.parse(modulePath).dir } else {