fix: plugin does not exist

This commit is contained in:
chenos 2024-01-02 12:32:47 +08:00
parent 0dbc01c330
commit 29b47c1d40

View File

@ -83,12 +83,10 @@ export class PluginManager {
static async getPackageName(name: string) { static async getPackageName(name: string) {
const prefixes = this.getPluginPkgPrefix(); const prefixes = this.getPluginPkgPrefix();
for (const prefix of prefixes) { for (const prefix of prefixes) {
try { const pkg = resolve(process.env.NODE_MODULES_PATH, `${prefix}${name}`, 'package.json');
await import(`${prefix}${name}`); const exists = await fsExists(pkg);
if (exists) {
return `${prefix}${name}`; return `${prefix}${name}`;
} catch (error) {
// console.log(error);
continue;
} }
} }
throw new Error(`${name} plugin does not exist`); throw new Error(`${name} plugin does not exist`);