dasilvacontin / dot-only-hunter

:squirrel: Hunt down `.only`s before it's too late.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dot-only-hunter reports success if `grep` returns an error

jamiemjennings opened this issue · comments

The expected exit codes for grep are:

     0     One or more lines were selected.
     1     No lines were selected.
     >1    An error occurred.

Currently, dot-only-hunter only checks for an exit code of 1, in which case it fails (exit 1), otherwise it reports success. If grep reports an error (exit code greater than 1, the search did not actually happen however dot-only-hunter will still report success.

See https://github.com/dasilvacontin/dot-only-hunter/blob/master/bin/dot-only-hunter#L50-L55
ie:

  if grep -nR "\($prey\)\.only" "$test_dir"; then
    echo "Whoops! Found \`.only\` in your tests."
    exit 1
  fi

  echo "All good!"