egg-core
Advanced tools
Comparing version 4.25.0 to 4.26.0
4.26.0 / 2022-09-07 | ||
================== | ||
**features** | ||
* [[`7c6353f`](http://github.com/eggjs/egg-core/commit/7c6353f1dfe2ed4ebf0d9ae432356608372664bd)] - feat: extract plugin loader method for override (#246) (TZ | 天猪 <<atian25@qq.com>>) | ||
4.25.0 / 2022-09-07 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -62,5 +62,6 @@ 'use strict'; | ||
this.lookupDirs = this.getLookupDirs(); | ||
this.allPlugins = {}; | ||
this.eggPlugins = this.loadEggPlugins(); | ||
this.appPlugins = this.loadAppPlugins(); | ||
this.eggPlugins = this.loadEggPlugins(); | ||
this.customPlugins = this.loadCustomPlugins(); | ||
@@ -340,13 +341,3 @@ | ||
// Get the real plugin path | ||
getPluginPath(plugin) { | ||
if (plugin.path) { | ||
return plugin.path; | ||
} | ||
if (plugin.package) { | ||
assert(isValidatePackageName(plugin.package), `plugin ${plugin.name} invalid, use 'path' instead of package: "${plugin.package}"`); | ||
} | ||
const name = plugin.package || plugin.name; | ||
getLookupDirs() { | ||
const lookupDirs = new Set(); | ||
@@ -367,2 +358,21 @@ | ||
return lookupDirs; | ||
}, | ||
// Get the real plugin path | ||
getPluginPath(plugin) { | ||
if (plugin.path) { | ||
return plugin.path; | ||
} | ||
if (plugin.package) { | ||
assert(isValidatePackageName(plugin.package), `plugin ${plugin.name} invalid, use 'path' instead of package: "${plugin.package}"`); | ||
} | ||
return this._resolvePluginPath(plugin); | ||
}, | ||
_resolvePluginPath(plugin) { | ||
const name = plugin.package || plugin.name; | ||
try { | ||
@@ -375,6 +385,6 @@ // should find the plugin directory | ||
// 'node_modules/.pnpm/egg@2.33.1/node_modules', <- this is the sibling directory | ||
const filePath = require.resolve(`${name}/package.json`, { paths: [ ...lookupDirs ] }); | ||
const filePath = require.resolve(`${name}/package.json`, { paths: [ ...this.lookupDirs ] }); | ||
return path.dirname(filePath); | ||
} catch (_) { | ||
throw new Error(`Can not find plugin ${name} in "${[ ...lookupDirs ].join(', ')}"`); | ||
throw new Error(`Can not find plugin ${name} in "${[ ...this.lookupDirs ].join(', ')}"`); | ||
} | ||
@@ -381,0 +391,0 @@ }, |
{ | ||
"name": "egg-core", | ||
"version": "4.25.0", | ||
"version": "4.26.0", | ||
"description": "A core Pluggable framework based on koa", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135710
2996