2025-03-23 23:22:22 +02:00
|
|
|
const child_process = require("child_process");
|
2025-04-27 23:47:51 +03:00
|
|
|
const fs = require("fs");
|
2025-04-28 20:24:01 +03:00
|
|
|
const { default: path } = require("path");
|
2025-03-23 23:22:22 +02:00
|
|
|
|
|
|
|
module.exports = function (filePath) {
|
2025-03-24 17:00:37 +02:00
|
|
|
const { WINDOWS_SIGN_EXECUTABLE } = process.env;
|
|
|
|
|
|
|
|
if (!WINDOWS_SIGN_EXECUTABLE) {
|
|
|
|
console.warn("[Sign] Skip signing due to missing environment variable.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-04-28 20:24:01 +03:00
|
|
|
console.log(filePath, fs.realpathSync(filePath));
|
|
|
|
filePath = fs.realpathSync(filePath);
|
|
|
|
|
2025-04-28 20:38:22 +03:00
|
|
|
console.log(fs.readFileSync(filePath).subarray(0, 100));
|
|
|
|
|
2025-03-24 17:00:37 +02:00
|
|
|
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${filePath}"`;
|
2025-03-24 12:05:46 +02:00
|
|
|
console.log(`[Sign] ${command}`);
|
2025-04-27 23:47:51 +03:00
|
|
|
|
2025-04-28 20:09:27 +03:00
|
|
|
try {
|
|
|
|
child_process.execSync(command);
|
|
|
|
} catch (e) {
|
2025-04-28 20:20:16 +03:00
|
|
|
console.error("[Sign] Got error while signing " + e.output.toString("utf-8"));
|
|
|
|
process.exit(1);
|
2025-04-28 20:09:27 +03:00
|
|
|
}
|
2025-03-23 23:22:22 +02:00
|
|
|
}
|