#!/bin/bash
# Script to run a given test against the monorepo.
#
# Set up paths so that `cdk` binary is on the path, and make it
# so that `npm install` symlinks from the monorepo package directories.
set -eu

cli_dir=$(cd $(dirname $0)/../.. && pwd)
repo_root=$(cd $cli_dir/../.. && pwd)

if [[ ! -f $repo_root/package.json ]]; then
    echo "$repo_root does not seem to be the root of the aws-cdk repository." >&2
    exit 1
fi

export REPO_ROOT="$repo_root"
export ORIGINAL_NPM="$(type -p npm)"
export TEST_RUNNER=repo

export PATH="$cli_dir/bin:$cli_dir/test/integ/run-wrappers/repo:$PATH"
hash -r
exec "$@"
