From a780691ea56885fb8e466ddf5444efb540ed8b86 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sat, 12 Dec 2020 11:41:32 +0800 Subject: [PATCH] fix(load_plugins): prevent hexo-theme being loaded as plugin (#4592) --- lib/hexo/load_plugins.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/hexo/load_plugins.js b/lib/hexo/load_plugins.js index 4f678d78c4..03f733b3a9 100644 --- a/lib/hexo/load_plugins.js +++ b/lib/hexo/load_plugins.js @@ -12,16 +12,6 @@ module.exports = ctx => { }; function loadModuleList(ctx) { - let customThemeName; - - if (ctx.config) { - const { theme } = ctx.config; - - if (theme) { - customThemeName = String(theme); - } - } - const packagePath = join(ctx.base_dir, 'package.json'); // Make sure package.json exists @@ -37,12 +27,12 @@ function loadModuleList(ctx) { return deps.concat(devDeps); }); }).filter(name => { - // Ignore plugin whose name endswith "hexo-theme-[ctx.config.theme]" - if (name.endsWith(`hexo-theme-${customThemeName}`)) return false; - // Ignore plugins whose name is not started with "hexo-" if (!/^hexo-|^@[^/]+\/hexo-/.test(name)) return false; + // Ignore plugin whose name is started with "hexo-theme" + if (/^hexo-theme-|^@[^/]+\/hexo-theme-/.test(name)) return false; + // Ignore typescript definition file that is started with "@types/" if (name.startsWith('@types/')) return false;