forked from retyui/react-native-confirmation-code-field
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path-rn-62.js
31 lines (26 loc) · 932 Bytes
/
path-rn-62.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
const {writeFileSync, readFileSync} = require('fs');
// TODO https://github.com/facebook/react-native/pull/28224
try {
const textInputPath = require.resolve(
'react-native/Libraries/Components/TextInput/TextInput.js',
);
const text = readFileSync(textInputPath).toString();
const PATTERN_0_62x = 'onPress={_onPress}';
const PATH_ON_PRESS_0_62x =
'onPress={e => {_onPress(e);if (props.onPress) {props.onPress(e);}}}';
if (text.includes(PATTERN_0_62x)) {
return writeFileSync(
textInputPath,
text.replace(PATTERN_0_62x, PATH_ON_PRESS_0_62x),
);
}
const PATTERN_0_61x = /onPress={this\._onPress}/g;
const PATH_ON_PRESS_0_61x =
'onPress={e => {this._onPress(e);if (this.props.onPress) {this.props.onPress(e);}}}';
if (PATTERN_0_61x.test(text)) {
return writeFileSync(
textInputPath,
text.replace(PATTERN_0_61x, PATH_ON_PRESS_0_61x),
);
}
} catch (error) {}