26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
// patch-resvg-freebsd-runtime.mjs
|
|
// Patch script to restore FreeBSD resvg-js native binary from cache
|
|
// Usage: node scripts/patch-resvg-freebsd-runtime.mjs
|
|
|
|
import { existsSync, copyFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
const MARKER = '[patch] resvg-js freebsd binary restore';
|
|
const RESVG_VERSION = require('../node_modules/@resvg/resvg-js/package.json').version;
|
|
const CACHE_DIR = `/usr/local/git/.cache/resvg-freebsd/`;
|
|
const CACHE_FILE = join(CACHE_DIR, `resvg-freebsd-x64-${RESVG_VERSION}.node`);
|
|
const DEST_DIR = join(process.cwd(), 'node_modules', '@resvg', 'resvg-js', 'linux-x64'); // Use linux-x64 as fallback if no freebsd dir
|
|
const DEST_FILE = join(DEST_DIR, 'resvg-js.node');
|
|
|
|
if (!existsSync(CACHE_FILE)) {
|
|
console.warn(`${MARKER}: Cached FreeBSD resvg-js binary not found at ${CACHE_FILE}`);
|
|
process.exit(0);
|
|
}
|
|
|
|
if (!existsSync(DEST_DIR)) {
|
|
require('fs').mkdirSync(DEST_DIR, { recursive: true });
|
|
}
|
|
|
|
copyFileSync(CACHE_FILE, DEST_FILE);
|
|
console.log(`${MARKER}: Restored resvg-js FreeBSD binary to ${DEST_FILE}`);
|