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