import * as fs from './fs' ; import * as path from './path' ; import { logInfo } from '../helpers' ; import { Config } from '../types' ; const kNativeConstantsPlaceholder = '// [NativeConstants Inject]' ; param { object } configuration param { string } key param { string } value export function addAndroid ( configuration , key , value ) { const constantsPath = path . resolve ( path . android . nativeProjectPath ( configuration ) , 'NativeConstants.java' ) ; logInfo ( `injecting Android native constant ${ key }` ) ; fs . update ( constantsPath , kNativeConstantsPlaceholder , [ kNativeConstantsPlaceholder , `constants.put("${ key }", "${ value }");` ] . join ( '\n' ) ) ; } param { object } configuration param { string } key param { string } value export function addIOS ( configuration , key , value ) { const constantsPath = path . resolve ( path . ios . nativeProjectPath ( configuration ) , 'NativeConstants.m' ) ; logInfo ( `injecting iOS native constant ${ key }` ) ; fs . update ( constantsPath , kNativeConstantsPlaceholder , [ kNativeConstantsPlaceholder , `, @"${ key }": @"${ value }"` ] . join ( '\n' ) ) ; }