(payload: ImportPayload)
| 11 | } |
| 12 | |
| 13 | function detectSnippetSource(payload: ImportPayload): ImportSource { |
| 14 | if (payload.url?.trim()) { |
| 15 | return 'github-gists' |
| 16 | } |
| 17 | |
| 18 | const snippetsLab = parseSnippetsLabFiles(payload.files || []) |
| 19 | if (snippetsLab.snippets.length > 0) { |
| 20 | return 'snippetslab' |
| 21 | } |
| 22 | |
| 23 | const raycast = parseRaycastSnippetFiles(payload.files || []) |
| 24 | const vscode = parseVSCodeSnippetFiles(payload.files || []) |
| 25 | |
| 26 | if (raycast.snippets.length > 0 || vscode.snippets.length > 0) { |
| 27 | return raycast.snippets.length >= vscode.snippets.length |
| 28 | ? 'raycast-snippets' |
| 29 | : 'vscode-snippets' |
| 30 | } |
| 31 | |
| 32 | throw new Error('Import format could not be detected') |
| 33 | } |
| 34 | |
| 35 | export function detectImportSource( |
| 36 | source: ImportSource | undefined, |
no test coverage detected