mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-19 16:21:25 +01:00
NodeJS Plugin Runtime (#53)
This commit is contained in:
18
plugin-runtime/src/plugins.ts
Normal file
18
plugin-runtime/src/plugins.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { PluginHandle } from './PluginHandle';
|
||||
|
||||
export interface PluginInfo {
|
||||
name: string;
|
||||
dir: string;
|
||||
capabilities: ('import' | 'export' | 'filter')[];
|
||||
}
|
||||
|
||||
export function loadPlugins(workerJsPath: string): PluginHandle[] {
|
||||
const pluginsDir = process.env.PLUGINS_DIR;
|
||||
if (!pluginsDir) throw new Error('PLUGINS_DIR is not set');
|
||||
console.log('Loading plugins from', pluginsDir);
|
||||
|
||||
const pluginDirs = fs.readdirSync(pluginsDir).map((p) => path.join(pluginsDir, p));
|
||||
return pluginDirs.map((pluginDir) => new PluginHandle({ pluginDir, workerJsPath }));
|
||||
}
|
||||
Reference in New Issue
Block a user