Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import type { AssetGenerator, LocalsType, NodeJSLikeCallback, NormalPageGenerato
import type { AddSchemaTypeOptions } from 'warehouse/dist/types';
import type Schema from 'warehouse/dist/schema';

let resolveSync; // = require('resolve');

const libDir = dirname(__dirname);
const dbVersion = 1;

Expand Down Expand Up @@ -457,16 +455,9 @@ class Hexo extends EventEmitter {
// Try to resolve the plugin with the Node.js's built-in require.resolve.
return require.resolve(name, { paths: [basedir] });
} catch (err) {
try {
// There was an error (likely the node_modules is corrupt or from early version of npm)
// Use Hexo prior 6.0.0's behavior (resolve.sync) to resolve the plugin.
resolveSync = resolveSync || require('resolve').sync;
return resolveSync(name, { basedir });
} catch (err) {
// There was an error (likely the plugin wasn't found), so return a possibly
// non-existing path that a later part of the resolution process will check.
return join(basedir, 'node_modules', name);
}
// There was an error (likely the node_modules is corrupt or from early version of npm),
// so return a possibly non-existing path that a later part of the resolution process will check.
return join(basedir, 'node_modules', name);
}
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"nunjucks": "^3.2.3",
"picocolors": "^1.0.0",
"pretty-hrtime": "^1.0.3",
"resolve": "^1.22.0",
"strip-ansi": "^6.0.0",
"text-table": "^0.2.0",
"tildify": "^2.0.0",
Expand Down
Loading