chore(nx/forge): print signing logs on error

This commit is contained in:
Elian Doran 2025-04-28 21:57:48 +03:00
parent 6aaacd6ca1
commit 546bb52abe
No known key found for this signature in database

View File

@ -3,17 +3,14 @@ const { default: e } = require("express");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const LOG_LOCATION = "c:\\ev_signer_trilium\\ev_signer_trilium.err.log";
module.exports = function (sourcePath) { module.exports = function (sourcePath) {
const { WINDOWS_SIGN_EXECUTABLE } = process.env; const { WINDOWS_SIGN_EXECUTABLE } = process.env;
if (!WINDOWS_SIGN_EXECUTABLE) { if (!WINDOWS_SIGN_EXECUTABLE) {
console.warn("[Sign] Skip signing due to missing environment variable."); console.warn("[Sign] Skip signing due to missing environment variable.");
return; return;
} }
const buffer = fs.readFileSync(sourcePath);
console.log("Platform: ", process.platform);
console.log("CPU archi:", process.arch);
console.log("DLL archi: ", getDllArchitectureFromBuffer(buffer));
try { try {
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${sourcePath}"`; const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${sourcePath}"`;
@ -22,10 +19,26 @@ module.exports = function (sourcePath) {
child_process.execSync(command); child_process.execSync(command);
} catch (e) { } catch (e) {
console.error("[Sign] Got error while signing " + e.output.toString("utf-8")); console.error("[Sign] Got error while signing " + e.output.toString("utf-8"));
printSigningErrorLogs(sourcePath);
process.exit(2); process.exit(2);
} }
} }
function printSigningErrorLogs(sourcePath) {
const buffer = fs.readFileSync(sourcePath);
console.log("Platform: ", process.platform);
console.log("CPU archi:", process.arch);
console.log("DLL archi: ", getDllArchitectureFromBuffer(buffer));
if (!fs.existsSync(LOG_LOCATION)) {
console.warn("[Sign] No debug log file found.");
return;
}
const logContent = fs.readFileSync(LOG_LOCATION, "utf-8");
console.error("[Sign] Debug log content:\n" + logContent);
}
function getDllArchitectureFromBuffer(buffer) { function getDllArchitectureFromBuffer(buffer) {
// Check for MZ header // Check for MZ header
if (buffer[0] !== 0x4D || buffer[1] !== 0x5A) { if (buffer[0] !== 0x4D || buffer[1] !== 0x5A) {