#!/usr/bin/env bash
# ---
# Add your own commands, functions, and variables here.  Define defaults first,
# then `dk use:` the desired devkit modules, and then define any overrides to
# the devkit defaults.
# ---

# Available modules (uncomment to use):

dk use: peridot           # run tests using peridot-php
dk use: cram              # run tests using the "cram" functional test tool

dk use: entr-watch        # watch files and re-run tests or other commands
dk use: shell-console     # make the "console" command enter a subshell
dk use: composer          # utilities for accessing composer-based dev tools
dk use: bash-kit          # enable doing tests/console/etc. in bash w/docker
dk use: shellcheck        # support running shellcheck (via docker if not installed)

# Define overrides, new commands, functions, etc. here:

# SC1090 = dynamic 'source' command
# SC2016 = expressions in single quotes
# SC2128 = array/string mixing
# SC2145 = prefix or suffix on "$@" or other array
# SC2178 = array/string mixing
# SC2179 = array/string mixing
# SC2241 = exit w/message

SHELLCHECK_OPTS='-e SC1090,SC2016,SC2128,SC2145,SC2178,SC2179,SC2241'

[[ -f composer.lock ]] || on boot composer install

build-imposer() { jqmd -R --out "$1" --compile imposer.md && chmod +x "$1"; }

on build build-imposer bin/imposer

before test build-imposer "$BASHER_INSTALL_BIN"/imposer
on test  eval 'dk shellcheck /dev/stdin < <(jqmd -R --compile imposer.md)'

on "test_files" eval 'ls src/*.php'

# When watching, use the spec reporter
before "files_changed" export PERIDOT_OPTIONS="-r spec"

# But use the dot reporter for plain "Test"
export PERIDOT_OPTIONS="-r dot"

dk.unit()     { peridot --watch --force-colors specs; }