Skip to content

Commit

Permalink
fix(load_plugins): prevent hexo-theme being loaded as plugin (#4592)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Dec 12, 2020
1 parent 35ca7bb commit a780691
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/hexo/load_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit a780691

Please sign in to comment.