Skip to content

Commit

Permalink
fix: support symlinks when commit signing (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans authored Sep 18, 2024
1 parent 2f38cd2 commit 5e91468
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,13 @@ function readFile(path) {
return fs.readFileSync(path, 'utf-8');
}
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 */
function hasErrorCode(error) {
Expand Down
8 changes: 7 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export function readFile(path: 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 */
Expand Down

0 comments on commit 5e91468

Please sign in to comment.