chore(nx/forge): try to copy the file instead

This commit is contained in:
Elian Doran 2025-04-28 20:51:44 +03:00
parent 9bf1e7b0b6
commit ea4f5f157e
No known key found for this signature in database

View File

@ -1,8 +1,8 @@
const child_process = require("child_process");
const fs = require("fs");
const { default: path } = require("path");
const path = require("path");
module.exports = function (filePath) {
module.exports = function (sourcePath) {
const { WINDOWS_SIGN_EXECUTABLE } = process.env;
if (!WINDOWS_SIGN_EXECUTABLE) {
@ -10,18 +10,23 @@ module.exports = function (filePath) {
return;
}
console.log(filePath, fs.realpathSync(filePath));
filePath = fs.realpathSync(filePath);
const destPath = path.resolve(path.basename(sourcePath));
try {
fs.copyFileSync(sourcePath, destPath);
} catch (e) {
console.error(`Unable to copy ${sourcePath} -> ${destPath}: ${e.message}`);
process.exit(1);
}
console.log(fs.readFileSync(filePath).subarray(0, 100));
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${filePath}"`;
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${destPath}"`;
console.log(`[Sign] ${command}`);
try {
child_process.execSync(command);
} catch (e) {
console.error("[Sign] Got error while signing " + e.output.toString("utf-8"));
process.exit(1);
process.exit(2);
} finally {
fs.rmSync(destPath);
}
}