fix: 修复内置插件运行态路径
This commit is contained in:
parent
2064fdf014
commit
1f73673ebe
@ -177,7 +177,7 @@ export class QqbotBuiltinPluginPackageLoaderService {
|
||||
`src/modules/qqbot/plugins/${pluginKey}`,
|
||||
);
|
||||
if (existsSync(join(sourceRoot, 'plugin.json'))) return sourceRoot;
|
||||
return join(__dirname, `../../../plugins/${pluginKey}`);
|
||||
return join(__dirname, `../../../../plugins/${pluginKey}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { QqbotBuiltinPluginPackageLoaderService } from '@/modules/qqbot/plugin-platform/infrastructure/integration/package/builtin-plugin-package-loader.service';
|
||||
|
||||
describe('QqbotBuiltinPluginPackageLoaderService', () => {
|
||||
const createLoader = () =>
|
||||
new QqbotBuiltinPluginPackageLoaderService(
|
||||
{} as any,
|
||||
{} as any,
|
||||
{} as any,
|
||||
{} as any,
|
||||
{} as any,
|
||||
{} as any,
|
||||
) as any;
|
||||
|
||||
it('resolves built-in plugin manifests from compiled qqbot plugin package root', () => {
|
||||
const originalCwd = process.cwd();
|
||||
const sandbox = mkdtempSync(join(tmpdir(), 'kt-plugin-loader-'));
|
||||
|
||||
try {
|
||||
process.chdir(sandbox);
|
||||
|
||||
const pluginRoot = createLoader().resolvePluginRoot('bangdream') as string;
|
||||
const normalized = pluginRoot.replace(/\\/g, '/');
|
||||
|
||||
expect(normalized).toMatch(/modules\/qqbot\/plugins\/bangdream$/);
|
||||
expect(normalized).not.toContain('/plugin-platform/plugins/');
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
rmSync(sandbox, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user