From 5e914681df9dc83aa4e4905692ca88beb2f9e91f Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:40:10 +0100 Subject: [PATCH] fix: support symlinks when commit signing (#3359) --- dist/index.js | 8 +++++++- src/utils.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5905299db1..5f84df99d9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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) { diff --git a/src/utils.ts b/src/utils.ts index ebde59ed88..ced3cbdfb6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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 */