| 30 | } |
| 31 | |
| 32 | export async function loadFigSpec( |
| 33 | command: string, |
| 34 | ): Promise<CommandSpec | null> { |
| 35 | if (!command || command.includes('/') || command.includes('\\')) return null |
| 36 | if (command.includes('..')) return null |
| 37 | if (command.startsWith('-') && command !== '-') return null |
| 38 | |
| 39 | try { |
| 40 | const module = await import(`@withfig/autocomplete/build/${command}.js`) |
| 41 | return module.default || module |
| 42 | } catch { |
| 43 | return null |
| 44 | } |
| 45 | } |
| 46 | export const getCommandSpec = memoizeWithLRU( |
| 47 | async (command: string): Promise<CommandSpec | null> => { |
| 48 | const spec = |