#!/bin/bash -e
# enableCodePush.sh
#
# Enable/disable Prod CodePush

if [ -z "$1" ]
then
    echo "enable is not specified"
    exit 1
fi

enable=$1

file="./jenkins/config.groovy"
searchPattern="prodCodePushEnabled"
replacement="    prodCodePushEnabled: $enable,"

if grep -q "$searchPattern" "$file"; then
  sed -i '' "/$searchPattern/s/.*/$replacement/" "$file"
else
  echo "Error: '$searchPattern' not found in the $file file."
  exit 1
fi
