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