I think you mean this:

    if command -v brew > /dev/null; then
      # ...
    fi