Skip to content

Instantly share code, notes, and snippets.

@dennyweiss
Created June 11, 2016 10:45
Show Gist options
  • Save dennyweiss/14e6087edb86f1fedef519248bd4bae1 to your computer and use it in GitHub Desktop.
Save dennyweiss/14e6087edb86f1fedef519248bd4bae1 to your computer and use it in GitHub Desktop.
Run phpspec through phpstorm filewatcher
#!/usr/bin/env bash
FILE_PATH="${1}"
PHPSPEC_PATH="bin/phpspec"
if [[ "${FILE_PATH}" == "" ]]; then
echo "File path missing"
exit 1
fi
if [ ! -f "${PHPSPEC_PATH}" ]; then
echo "Could not find phpspec bin at path: '${PHPSPEC_PATH}'"
exit 1
fi
if [[ "${FILE_PATH}" =~ 'Spec.php' && "${FILE_PATH}" =~ 'spec/' ]]; then
FILE_PATH="$(echo "${FILE_PATH}" | sed "s|spec/|src/|" | sed "s|Spec\.php|\.php|")"
fi
eval "${PHPSPEC_PATH}" "run" "${FILE_PATH}" "-v --format=pretty --ansi"
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment