Files
koodo-reader/scripts/patch-nan.js
troyeguo 30f6553b11 feat: add Discord Rich Presence support
- Added translation for "Enable Discord Rich Presence" and its description in Chinese.
- Introduced a new setting option for enabling Discord Rich Presence in the settings panel.
- Implemented functionality to update Discord Rich Presence with the current book information when reading.
- Added methods to clear Discord Rich Presence when the reader is closed.
- Updated the percentage display in the reading progress to show as a percentage.
2026-04-07 09:37:59 +08:00

27 lines
752 B
JavaScript

/**
* Cross-platform replacement for the sed command in postinstall.
* Patches nan.h to comment out the #include nan_scriptorigin.h line.
*/
const fs = require("fs");
const path = require("path");
const nanHPath = path.join(__dirname, "..", "node_modules", "nan", "nan.h");
if (!fs.existsSync(nanHPath)) {
console.log("nan.h not found, skipping patch.");
process.exit(0);
}
let content = fs.readFileSync(nanHPath, "utf8");
const patched = content.replace(
/^#include [<"]nan_scriptorigin\.h[>"]/m,
"// #include nan_scriptorigin.h"
);
if (content === patched) {
console.log("nan.h already patched or pattern not found, skipping.");
} else {
fs.writeFileSync(nanHPath, patched, "utf8");
console.log("nan.h patched successfully.");
}