forked from iyegoroff/react-native-text-gradient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-rn.js
29 lines (21 loc) · 808 Bytes
/
patch-rn.js
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
27
28
29
#!/usr/bin/env node
const { writeFile, readFile, readdir } = require('fs');
const { promisify } = require('util');
const path = require('path');
const folder = 'node_modules/react-native/Libraries/Renderer/oss/';
const pattern = new RegExp(
'invariant\\([\\s\\S]{0,20}' +
'(hostContext|type)\\.isInAParentText,[\\s\\S]{0,20}' +
'"Text strings must be rendered within a <Text> component\\."[\\s\\S]{0,20}' +
'\\)[;,]'
);
const patchFile = async (file) => {
const content = (await promisify(readFile)(file)).toString();
const patched = content.replace(pattern, '');
await promisify(writeFile)(file, patched);
};
const patchAll = async () => {
const files = await promisify(readdir)(folder);
await Promise.all(files.map(file => path.join(folder, file)).map(patchFile));
};
patchAll();