#!/usr/bin/env bash

set -e            # fail fast
set -o pipefail   # don't ignore exit codes when piping output
# set -x          # enable debugging

# Configure directories
build_dir=$1
cache_dir=$2
env_dir=$3

bp_dir=$(cd $(dirname $0); cd ..; pwd)

# Load some convenience functions like status() and indent()
source $bp_dir/bin/common.sh

# Output npm debug info on error
trap cat_npm_debug_log ERR

# Run subsequent node/npm commands from the build path
cd $build_dir

# Run twice as we may be able to remove a few more dependencies
# on the second run
status "Pruning development dependencies"
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent
