mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(sign): use sign code known to work
This commit is contained in:
parent
ebab12dcc2
commit
de2de04f35
@ -1,38 +1,29 @@
|
|||||||
const child_process = require("child_process");
|
const child_process = require("child_process");
|
||||||
const path = require("path");
|
const fs = require("fs");
|
||||||
const { WINDOWS_SIGN_EXECUTABLE } = process.env;
|
const { default: path } = require("path");
|
||||||
|
|
||||||
|
module.exports = function (filePath) {
|
||||||
|
const { WINDOWS_SIGN_EXECUTABLE } = process.env;
|
||||||
|
|
||||||
|
const stats = fs.lstatSync(filePath);
|
||||||
|
console.log(filePath, stats);
|
||||||
|
|
||||||
function sign(sourcePath) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.extname(sourcePath) !== ".exe") {
|
const outputDir = path.join(__dirname, "sign");
|
||||||
console.warn("[Sign] Unsupported extension for signing: ", sourcePath);
|
console.log("Output dir is ", path.resolve(outputDir));
|
||||||
return;
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
fs.copyFileSync(sourcePath, destPath);
|
||||||
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${sourcePath}"`;
|
|
||||||
child_process.execSync(command);
|
|
||||||
console.log(`[Sign] ${command}: SUCCESS`);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[Sign] ${command}: FAILED: `, e.output.toString("utf-8"));
|
|
||||||
printSigningErrorLogs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function printSigningErrorLogs() {
|
const command = `${WINDOWS_SIGN_EXECUTABLE} --executable "${filePath}"`;
|
||||||
const logLocation = path.join(path.dirname(WINDOWS_SIGN_EXECUTABLE), "ev_signer_trilium.err.log");
|
console.log(`[Sign] ${command}`);
|
||||||
|
|
||||||
if (!fs.existsSync(logLocation)) {
|
const output = child_process.execSync(command);
|
||||||
console.warn("[Sign] No debug log file found.");
|
console.log(`[Sign] ${output}`);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const logContent = fs.readFileSync(logLocation, "utf-8");
|
|
||||||
console.error("[Sign] Debug log content:\n" + logContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = sign;
|
|
Loading…
x
Reference in New Issue
Block a user