diff --git a/packages/core/server/src/plugin-manager/plugin-manager.ts b/packages/core/server/src/plugin-manager/plugin-manager.ts index 960be122b..49500785e 100644 --- a/packages/core/server/src/plugin-manager/plugin-manager.ts +++ b/packages/core/server/src/plugin-manager/plugin-manager.ts @@ -357,19 +357,25 @@ export class PluginManager { enabled: true, }, }); - let sourceDir = basename(dirname(__dirname)) === 'src' ? 'src' : 'dist'; const packageNames: string[] = items.map((item) => item.packageName); const source = []; for (const packageName of packageNames) { - const directory = join(packageName, sourceDir, 'server/commands/*.' + (sourceDir === 'src' ? 'ts' : 'js')); - source.push(directory); + const file = require.resolve(packageName); + const sourceDir = basename(dirname(file)) === 'src' ? 'src' : 'dist'; + const directory = join( + packageName, + sourceDir, + 'server/commands/*.' + (basename(dirname(file)) === 'src' ? 'ts' : 'js'), + ); + source.push(directory.replaceAll(sep, '/')); } - sourceDir = basename(dirname(__dirname)) === 'src' ? 'src' : 'lib'; for (const plugin of this.options.plugins || []) { if (typeof plugin === 'string') { const packageName = await PluginManager.getPackageName(plugin); + const file = require.resolve(packageName); + const sourceDir = basename(dirname(file)) === 'src' ? 'src' : 'lib'; const directory = join(packageName, sourceDir, 'server/commands/*.' + (sourceDir === 'src' ? 'ts' : 'js')); - source.push(directory); + source.push(directory.replaceAll(sep, '/')); } } const files = await fg(source, {