|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +const fs = require('fs'); |
| 4 | +const { promisify } = require('util'); |
| 5 | +const glob = require('glob'); |
| 6 | + |
| 7 | +const patterns = [ |
| 8 | + new RegExp( |
| 9 | + 'type === "AndroidTextInput" \\\|\\| // Android[\\s\\S]+' + |
| 10 | + 'type === "RCTMultilineTextInputView" \\|\\| // iOS[\\s\\S]+' + |
| 11 | + 'type === "RCTSinglelineTextInputView" \\|\\| // iOS[\\s\\S]+' + |
| 12 | + 'type === "RCTText" \\|\\|[\\s\\S]+' + |
| 13 | + 'type === "RCTVirtualText"' |
| 14 | + ), |
| 15 | + |
| 16 | + new RegExp( |
| 17 | + '"AndroidTextInput" === props \\|\\|[\\s\\S]+' + |
| 18 | + '"RCTMultilineTextInputView" === props \\|\\|[\\s\\S]+' + |
| 19 | + '"RCTSinglelineTextInputView" === props \\|\\|[\\s\\S]+' + |
| 20 | + '"RCTText" === props \\|\\|[\\s\\S]+' + |
| 21 | + '"RCTVirtualText" === props' |
| 22 | + ) |
| 23 | +]; |
| 24 | + |
| 25 | +const patches = [ |
| 26 | + 'type.includes("Text")', |
| 27 | + |
| 28 | + 'props.includes("Text")' |
| 29 | +] |
| 30 | + |
| 31 | +const patchFile = async (file) => { |
| 32 | + const content = (await promisify(fs.readFile)(file)).toString(); |
| 33 | + const patched = content |
| 34 | + .replace(patterns[0], patches[0]) |
| 35 | + .replace(patterns[1], patches[1]) |
| 36 | + |
| 37 | + await promisify(fs.writeFile)(file, patched); |
| 38 | +}; |
| 39 | + |
| 40 | +const patchAll = async () => { |
| 41 | + const files = await promisify(glob)('node_modules/react-native/Libraries/Renderer/oss/*'); |
| 42 | + |
| 43 | + await Promise.all(files.map(patchFile)); |
| 44 | +}; |
| 45 | + |
| 46 | +patchAll(); |
0 commit comments