fix: collections were not automatically created when enabling the plugin (#5939)

* fix: collections were not automatically created when enabling the plugin

* fix: error
This commit is contained in:
chenos 2024-12-25 00:34:22 +08:00 committed by GitHub
parent 7a1385e158
commit a97f11dc71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,15 +141,12 @@ export class PluginManager {
* @internal * @internal
*/ */
static async getPackageName(name: string) { static async getPackageName(name: string) {
const prefixes = this.getPluginPkgPrefix(); const { packageName } = await this.parseName(name);
for (const prefix of prefixes) { const packageFile = resolve(process.env.NODE_MODULES_PATH, packageName, 'package.json');
const pkg = resolve(process.env.NODE_MODULES_PATH, `${prefix}${name}`, 'package.json'); if (!(await fs.exists(packageFile))) {
const exists = await fs.exists(pkg); return null;
if (exists) {
return `${prefix}${name}`;
}
} }
throw new Error(`${name} plugin does not exist`); return packageName;
} }
/** /**
@ -329,7 +326,9 @@ export class PluginManager {
try { try {
if (typeof plugin === 'string' && options.name && !options.packageName) { if (typeof plugin === 'string' && options.name && !options.packageName) {
const packageName = await PluginManager.getPackageName(options.name); const packageName = await PluginManager.getPackageName(options.name);
options['packageName'] = packageName; if (packageName) {
options['packageName'] = packageName;
}
} }
if (options.packageName) { if (options.packageName) {