Function
generateTemporaryCacheNameForPlugin
(
source: PluginSource,
)
Source from the content-addressed store, hash-verified
| 871 | * Generate a temporary cache name for a plugin |
| 872 | */ |
| 873 | export function generateTemporaryCacheNameForPlugin( |
| 874 | source: PluginSource, |
| 875 | ): string { |
| 876 | const timestamp = Date.now() |
| 877 | const random = Math.random().toString(36).substring(2, 8) |
| 878 | |
| 879 | let prefix: string |
| 880 | |
| 881 | if (typeof source === 'string') { |
| 882 | prefix = 'local' |
| 883 | } else { |
| 884 | switch (source.source) { |
| 885 | case 'npm': |
| 886 | prefix = 'npm' |
| 887 | break |
| 888 | case 'pip': |
| 889 | prefix = 'pip' |
| 890 | break |
| 891 | case 'github': |
| 892 | prefix = 'github' |
| 893 | break |
| 894 | case 'url': |
| 895 | prefix = 'git' |
| 896 | break |
| 897 | case 'git-subdir': |
| 898 | prefix = 'subdir' |
| 899 | break |
| 900 | default: |
| 901 | prefix = 'unknown' |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | return `temp_${prefix}_${timestamp}_${random}` |
| 906 | } |
| 907 | |
| 908 | /** |
| 909 | * Cache a plugin from an external source |
Tested by
no test coverage detected