Skip to content

Commit 2cb061d

Browse files
committed
Fix postlink for RN > 0.46
1 parent 07dc8c4 commit 2cb061d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/postlink

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ function shouldConfigurePlatform(platform) {
5858
// if a sentry.properties file exists for the platform we want to configure
5959
// without asking the user. This means that re-linking later will not
6060
// bring up a useless dialog.
61-
if (fs.existsSync(platform + '/sentry.properties')) {
61+
if (fs.existsSync(platform + '/sentry.properties') || fs.existsSync(process.cwd() + platform + '/sentry.properties')) {
6262
configurePlatform[platform] = true;
63+
let {dim} = chalk;
64+
console.log(dim(platform + '/sentry.properties already exists'));
6365
return Promise.resolve(true);
6466
}
67+
6568
considerShowingInfoHint();
6669
return inquirer
6770
.prompt([
@@ -216,7 +219,11 @@ function patchIndexJs(contents, filename) {
216219
if (!shouldConfigure) {
217220
return null;
218221
}
219-
222+
// if we match react-native-sentry somewhere, we already patched the file
223+
// and no longer need to
224+
if (contents.match('react-native-sentry')) {
225+
Promise.resolve(contents);
226+
}
220227
return getDsn(platform).then(function(dsn) {
221228
return Promise.resolve(
222229
contents.replace(/^([^]*)(import\s+[^;]*?;$)/m, function(match) {
@@ -258,15 +265,15 @@ function patchBuildGradle(contents) {
258265
function patchExistingXcodeBuildScripts(buildScripts) {
259266
for (let script of buildScripts) {
260267
if (
261-
!script.shellScript.match(/packager\/react-native-xcode\.sh\b/) ||
268+
!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/) ||
262269
script.shellScript.match(/sentry-cli\s+react-native[\s-]xcode/)
263270
) {
264271
continue;
265272
}
266273
let code = JSON.parse(script.shellScript);
267274
code =
268275
'export SENTRY_PROPERTIES=sentry.properties\n' +
269-
code.replace(/^.*?\/packager\/react-native-xcode\.sh\s*/m, function(match) {
276+
code.replace(/^.*?\/(packager|scripts)\/react-native-xcode\.sh\s*/m, function(match) {
270277
return (
271278
'../node_modules/sentry-cli-binary/bin/sentry-cli react-native xcode ' + match
272279
);

0 commit comments

Comments
 (0)