-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathrn.patch.gradle.properties.js
More file actions
executable file
·43 lines (34 loc) · 1.36 KB
/
rn.patch.gradle.properties.js
File metadata and controls
executable file
·43 lines (34 loc) · 1.36 KB
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
#!/usr/bin/env node
const fs = require('fs');
const { argv } = require('process');
const parseArgs = require('minimist');
const { debug } = require('@sentry/core');
debug.enable();
const args = parseArgs(argv.slice(2));
if (!args['gradle-properties']) {
throw new Error('Missing --gradle-properties');
}
if (!args['engine']) {
throw new Error('Missing --engine');
}
const enableHermes = args['engine'] === 'hermes' ? true : args['engine'] === 'jsc' ? false : null;
if (enableHermes === null) {
throw new Error('Invalid engine');
}
debug.log('Patching gradle.properties', args['gradle-properties']);
let content = fs.readFileSync(args['gradle-properties'], 'utf8');
const isHermesEnabled = content.includes('hermesEnabled=true');
if (enableHermes !== isHermesEnabled) {
const patch = enableHermes ? 'hermesEnabled=true' : 'hermesEnabled=false';
content = content.match(/hermesEnabled=.*/)
? content.replace(/hermesEnabled=.*/g, patch)
: content.concat(`\n${patch}`);
if (enableHermes) {
debug.log('Patching gradle.properties for Hermes');
} else {
debug.log('Patching gradle.properties for JSC');
}
}
content = content.replace(/reactNativeArchitectures=.*/g, 'reactNativeArchitectures=x86');
content = content.replace(/org.gradle.jvmargs=.*/g, 'org.gradle.jvmargs=-Xmx3072m -XX:MaxMetaspaceSize=512m');
fs.writeFileSync(args['gradle-properties'], content);