Merged in feat/common-package (pull request #2333)
feat: Add common package * Add isEdge, safeTry and dataCache to new common package * Add eslint and move prettier config * Fix yarn lock * Clean up tests * Add lint-staged config to common * Add missing dependencies Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { getPrefix } from "./getPrefix"
|
||||
|
||||
export function generateCacheKey(
|
||||
key: string | string[],
|
||||
options?: { includeGitHashInKey?: boolean }
|
||||
): string {
|
||||
const includeGitHashInKey = options?.includeGitHashInKey ?? true
|
||||
const keyArray = (Array.isArray(key) ? key : [key]).filter(Boolean)
|
||||
|
||||
if (keyArray.length === 0) {
|
||||
throw new Error("No keys provided")
|
||||
}
|
||||
|
||||
const prefix = getPrefix({
|
||||
includeGitHashInKey,
|
||||
includeBranchPrefix: true,
|
||||
})
|
||||
|
||||
const keyTokens = [prefix, keyArray.join("_")].filter(Boolean).join(":")
|
||||
|
||||
return keyTokens
|
||||
}
|
||||
Reference in New Issue
Block a user