mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-10-19 12:11:11 +08:00
b3afdc78a7
Cache keys have a hard limit of 512 characters, so we need to ensure that we don't generate a key longer than this. - Remove excess whitespace - Truncate to 400 characters Fixes #70
18 lines
516 B
TypeScript
18 lines
516 B
TypeScript
import * as path from 'path'
|
|
import * as glob from '@actions/glob'
|
|
|
|
export async function hashFiles(
|
|
baseDir: string,
|
|
patterns: string[] = ['**'],
|
|
followSymbolicLinks = false
|
|
): Promise<string | null> {
|
|
const combinedPatterns = patterns
|
|
.map(pattern => `${baseDir}${path.sep}${pattern}`)
|
|
.join('\n')
|
|
return glob.hashFiles(combinedPatterns, {followSymbolicLinks})
|
|
}
|
|
|
|
export function truncateArgs(args: string): string {
|
|
return args.trim().replace(/\s+/g, ' ').substr(0, 400)
|
|
}
|