fix(server): commands failed to load properly on Windows (#3858)

This commit is contained in:
chenos 2024-03-29 06:46:37 +08:00 committed by GitHub
parent 08162e1004
commit 0ec3ed3c54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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, {