import * as path from '../../path' ; import * as fs from '../../fs' ; import { Config } from '../../../types' ; import { logInfo } from '../../../helpers' ; param { object } configuration export function postLink ( configuration ) { logInfo ( 'patching Android for react-native-sensitive-info' ) ; const mainApplicationPath = path . android . mainApplicationPath ( configuration ) ; let mainApplication = fs . readFileSync ( mainApplicationPath , { encoding : 'utf8' } ) ; if ( mainApplication . indexOf ( 'RNSensitiveInfoPackage' ) > - 1 ) { logInfo ( 'react-native-sensitive-info is already linked in MainApplication.java' ) ; return ; } mainApplication = mainApplication . replace ( /(import com.facebook.react.ReactApplication;)/ , '$1\nimport br.com.classapp.RNSensitiveInfo.RNSensitiveInfoPackage;' ) ; mainApplication = mainApplication . replace ( /(new MainReactPackage\(\)\,)/ , '$1\n                new RNSensitiveInfoPackage(),' ) ; fs . writeFileSync ( mainApplicationPath , mainApplication , { encoding : 'utf8' } ) ; logInfo ( 'finished patching Android for react-native-sensitive-info' ) ; }