1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| const fs = require('fs'); const { resolve } = require('path'); const nmPath = resolve(__dirname, './node_modules');
console.log('[hack] support debug for android') path = resolve(nmPath, './react-native/Libraries/BatchedBridge/MessageQueue.js') content = fs.readFileSync(path, { encoding: 'utf-8'}) replace = `callNativeSyncHook( moduleID: number, methodID: number, params: any[], onFail: ?Function, onSucc: ?Function, ): any { const isDebuggingEnabled = (typeof atob !== 'undefined'); this.processCallbacks(moduleID, methodID, params, onFail, onSucc); if(!isDebuggingEnabled) { if (typeof global.nativeCallSyncHook == 'function') { return global.nativeCallSyncHook(moduleID, methodID, params); } return ''; } } ` fs.writeFileSync(path, content.replace(/callNativeSyncHook.+\n(.+\n)*/gm, replace))
|