-
-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathrn.patch.launch-arguments.js
More file actions
executable file
·46 lines (36 loc) · 1.18 KB
/
rn.patch.launch-arguments.js
File metadata and controls
executable file
·46 lines (36 loc) · 1.18 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
44
45
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { argv } = require('process');
const parseArgs = require('minimist');
const { debug } = require('@sentry/core');
debug.enable();
const args = parseArgs(argv.slice(2));
if (!args['app-dir']) {
throw new Error('Missing --app-dir');
}
const buildGradlePath = path.join(
args['app-dir'],
'node_modules',
'react-native-launch-arguments',
'android',
'build.gradle'
);
debug.log('Patching react-native-launch-arguments build.gradle', buildGradlePath);
if (!fs.existsSync(buildGradlePath)) {
debug.log('build.gradle not found, skipping patch');
return;
}
const buildGradle = fs.readFileSync(buildGradlePath, 'utf8');
// Replace destinationDir with destinationDirectory.get() for Gradle 9+ compatibility
const isPatched = buildGradle.includes('destinationDirectory.get()');
if (!isPatched) {
const patched = buildGradle.replace(
/\.destinationDir\b/g,
'.destinationDirectory.get()'
);
fs.writeFileSync(buildGradlePath, patched);
debug.log('Patched react-native-launch-arguments build.gradle successfully!');
} else {
debug.log('react-native-launch-arguments build.gradle is already patched!');
}