| 1234567891011121314151617181920212223242526272829303132333435 |
- /**
- * Postinstall script: patch fmode-ng console.log to silence HTTP request logging.
- * Runs after every pnpm/npm install to keep the patch applied.
- */
- import { readFileSync, writeFileSync, existsSync } from 'fs';
- const FILES = [
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.query.mjs',
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.object.mjs',
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.parse.mjs',
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.user.mjs',
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.cloud.mjs',
- 'node_modules/fmode-ng/esm2022/lib/core/parse/fmode.schema.mjs',
- 'node_modules/fmode-ng/fesm2022/fmode-ng.mjs',
- ];
- let patched = 0;
- for (const filePath of FILES) {
- if (!existsSync(filePath)) continue;
- let content = readFileSync(filePath, 'utf-8');
- // Comment out standalone console.log lines
- const before = content.length;
- content = content.replace(/^\s*console\.log\([^)]*\);?\s*$/gm, '');
- content = content.replace(/console\.log\(/g, '// console.log(');
- if (content.length !== before) {
- writeFileSync(filePath, content);
- patched++;
- }
- }
- if (patched > 0) {
- console.log(`[patch-fmode-logs] silenced ${patched} files`);
- }
|