fix: support symlinks when commit signing (#3359)

This commit is contained in:
Peter Evans 2024-09-18 18:40:10 +01:00 committed by GitHub
parent 2f38cd26bf
commit 5e914681df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

8
dist/index.js vendored
View file

@ -1781,7 +1781,13 @@ function readFile(path) {
return fs.readFileSync(path, 'utf-8'); return fs.readFileSync(path, 'utf-8');
} }
function readFileBase64(pathParts) { function readFileBase64(pathParts) {
return fs.readFileSync(path.resolve(...pathParts)).toString('base64'); const resolvedPath = path.resolve(...pathParts);
if (fs.lstatSync(resolvedPath).isSymbolicLink()) {
return fs
.readlinkSync(resolvedPath, { encoding: 'buffer' })
.toString('base64');
}
return fs.readFileSync(resolvedPath).toString('base64');
} }
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
function hasErrorCode(error) { function hasErrorCode(error) {

View file

@ -127,7 +127,13 @@ export function readFile(path: string): string {
} }
export function readFileBase64(pathParts: string[]): string { export function readFileBase64(pathParts: string[]): string {
return fs.readFileSync(path.resolve(...pathParts)).toString('base64') const resolvedPath = path.resolve(...pathParts)
if (fs.lstatSync(resolvedPath).isSymbolicLink()) {
return fs
.readlinkSync(resolvedPath, {encoding: 'buffer'})
.toString('base64')
}
return fs.readFileSync(resolvedPath).toString('base64')
} }
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */