diff --git a/dist/index.js b/dist/index.js index 5905299..5f84df9 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 ebde59e..ced3cbd 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 */