Lines 13-52javascript
16 helpers: { parseFlags, intFlag, monthEnd, addMonthsEnd, lastCompletedMonthEnd, money, pct, shapeRows },
18export async function loadPlugins(coreCommands) {
19 const dir = join(configDir(), "plugins");
22 files = readdirSync(dir)
23 .filter((f) => f.endsWith(".mjs"))
27 return { commands: {}, homeHelp: [] };
31 for (const file of files) {
32 const path = join(dir, file);
34 const module = await import(pathToFileURL(path).href);
35 const plugin = await module.default(api);
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/plugins.jsView on unpkg · L33 36 for (const [name, spec] of Object.entries(plugin.commands ?? {})) {
37 if (coreCommands.has(name) || commands[name]) {
38 process.stderr.write(`snowflake-axi: plugin ${file} skipped duplicate command '${name}'\n`);
41 commands[name] = spec;
43 homeHelp.push(...(plugin.homeHelp ?? []));
46 const message = error instanceof Error ? error.message : String(error);
47 process.stderr.write(`snowflake-axi: failed to load plugin ${file}: ${message}\n`);
50 return { commands, homeHelp };