forked from ifsnow/react-native-infinite-flatlist-patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch.js
executable file
·66 lines (58 loc) · 1.36 KB
/
patch.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const rootPath = path.join(__dirname, '.');
const packageFile = fs.readFileSync(`${rootPath}/../react-native/package.json`);
const package = JSON.parse(packageFile);
const version = package.version.split('.');
const majorVersion = parseInt(version[0], 10);
const minorVersion = parseInt(version[1], 10);
const patchVersion = parseInt(version[2], 10);
let patchDir = '';
switch (minorVersion) {
case 63:
patchDir = '0.63.0';
break;
case 62:
patchDir = '0.62.1';
break;
case 61:
patchDir = '0.61.5';
break;
case 60:
patchDir = '0.60.5';
break;
case 59:
if (patchVersion >= 8) {
patchDir = '0.59.8';
} else if (patchVersion >= 5) {
patchDir = '0.59.5';
} else if (patchVersion >= 3) {
patchDir = '0.59.3';
}
break;
case 58:
patchDir = '0.58.6';
break;
case 57:
case 56:
patchDir = '0.57.8';
break;
case 55:
patchDir = '0.55.4';
break;
case 54:
patchDir = '0.54.4';
break;
default:
break;
}
if (patchDir === '') {
console.log('[!] Unsupported react-native version!');
process.exit(1);
}
fs.copyFileSync(
`${rootPath}/patches/${patchDir}/VirtualizedList.js`,
`${rootPath}/../react-native/Libraries/Lists/VirtualizedList.js`,
);
console.log('[!] FlatList was patched!');