import { execSync as exec } from 'child_process' ; import * as fs from './fs' ; import * as helpers from '../helpers' ; import * as os from './os' ; import * as path from './path' ; /**
 * Performs a pod install.
 */ export function install ( ) { if ( os . linux ) { return ; } helpers . logInfo ( 'running pod install' ) ; try { exec ( `cd "${ path . project . resolve ( 'ios' ) }" && pod install` , { stdio : [ 0 , 1 , 2 ] } ) ; } catch ( err ) { helpers . logError ( 'pod install failed, here are the few things you can try to fix:\n' + `\t1. Run "brew install cocoapods" if don't have cocoapods installed\n` + `\t2. Run "pod repo update" to update your local spec repos` ) ; process . exit ( 1 ) ; } } param { string [ ] } pods param { string } podfilePath export function add ( pods , podfilePath = path . ios . podfilePath ( ) ) { if ( ! pods . length ) { return ; } const podfileContents = fs . readFileSync ( podfilePath , { encoding : 'utf8' } ) ; pods = pods . filter ( pod => podfileContents . indexOf ( pod ) === - 1 ) ; pods = pods . map ( pod => `\t${ pod }` ) ; fs . writeFileSync ( podfilePath , podfileContents . replace ( '# Add new pods below this line' , `${ pods . join ( '\n' ) }\n# Add new pods below this line` ) ) ; helpers . logInfo ( `Podfile updated: ${ pods . join ( ', ' ) }` ) ; } param { string [ ] } sources export function sources ( sources ) { if ( sources . length > 0 ) { helpers . logInfo ( 'adding additional pod sources: ' + sources . join ( ', ' ) ) ; let podfileContents = fs . readFileSync ( path . ios . podfilePath ( ) , 'utf8' ) ; podfileContents = podfileContents . replace ( '# ADDITIONAL_POD_SOURCES' , sources . map ( s => `source '${ s }'` ) . join ( '\n' ) ) ; fs . writeFileSync ( path . ios . podfilePath ( ) , podfileContents ) ; } }