Skip to content

Instantly share code, notes, and snippets.

@kbrandwijk
Created January 5, 2022 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbrandwijk/98916ba5eb8c281b86f3463a4b72d974 to your computer and use it in GitHub Desktop.
Save kbrandwijk/98916ba5eb8c281b86f3463a4b72d974 to your computer and use it in GitHub Desktop.
Object.defineProperty(exports, "__esModule", { value: true });
const configPlugins = require("@expo/config-plugins");
const withAppDelegate = (config) => { //refactor this part?
return configPlugins.withAppDelegate(config, async config => {
let res = config.modResults
// ROLLBAR import
if (!res.contents.includes("#import <RollbarReactNative/RollbarReactNative.h>")) {
res.contents = res.contents.replace(/#import "AppDelegate.h"/g, `#import "AppDelegate.h"\n#import <RollbarReactNative/RollbarReactNative.h>`);
}
// ROLLBAR
if (!res.contents.includes("RollbarReactNative initWithAccessToken")) {
res.contents = res.contents.replace(/self.launchOptions = launchOptions;/g, `self.launchOptions = launchOptions;\n[RollbarReactNative initWithAccessToken:@"${process.env.ROLLBAR_KEY}"];\n`);
}
return config;
});
};
exports.withAppDelegate = withAppDelegate;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment