Files
koodo-reader/scripts/patch-nan.js
troyeguo 4b32218321 feat(i18n): add script for managing translation files and patching nan.h
- Implemented a script to list locale folders and identify missing translation terms in English.
- Added functionality to copy missing terms from Chinese translations to English.
- Enhanced the script to fill in missing terms for other languages based on the updated English file.
- Created a patch script for nan.h to comment out the inclusion of nan_scriptorigin.h for cross-platform compatibility.
2026-04-07 08:59:10 +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.');
}