#!/usr/bin/env bash
set -e

BRANCH=rstudio/v1.3

PROGRAMS=("git" "npm")
for PROGRAM in "${PROGRAMS[@]}"; do
    if ! command -v "${PROGRAM}" &> /dev/null; then
        echo "program '${PROGRAM}' not found; exiting"
    fi
done

# check out our copy of ace
if [ ! -d rstudio-ace ]; then
    git clone https://github.com/rstudio/rstudio-ace
fi

cd rstudio-ace
git pull
git reset --hard "${BRANCH}"
git submodule update --init --recursive --force
npm install
cd ..

./build-ace

