Skip to content

Commit 5e91468

Browse files
authored
fix: support symlinks when commit signing (#3359)
1 parent 2f38cd2 commit 5e91468

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dist/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,13 @@ function readFile(path) {
17811781
return fs.readFileSync(path, 'utf-8');
17821782
}
17831783
function readFileBase64(pathParts) {
1784-
return fs.readFileSync(path.resolve(...pathParts)).toString('base64');
1784+
const resolvedPath = path.resolve(...pathParts);
1785+
if (fs.lstatSync(resolvedPath).isSymbolicLink()) {
1786+
return fs
1787+
.readlinkSync(resolvedPath, { encoding: 'buffer' })
1788+
.toString('base64');
1789+
}
1790+
return fs.readFileSync(resolvedPath).toString('base64');
17851791
}
17861792
/* eslint-disable @typescript-eslint/no-explicit-any */
17871793
function hasErrorCode(error) {

src/utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ export function readFile(path: string): string {
127127
}
128128

129129
export function readFileBase64(pathParts: string[]): string {
130-
return fs.readFileSync(path.resolve(...pathParts)).toString('base64')
130+
const resolvedPath = path.resolve(...pathParts)
131+
if (fs.lstatSync(resolvedPath).isSymbolicLink()) {
132+
return fs
133+
.readlinkSync(resolvedPath, {encoding: 'buffer'})
134+
.toString('base64')
135+
}
136+
return fs.readFileSync(resolvedPath).toString('base64')
131137
}
132138

133139
/* eslint-disable @typescript-eslint/no-explicit-any */

0 commit comments

Comments
 (0)