         options:
           livereload: true
         files: ['public/**/*']
+
+  grunt.registerTask 'checkDatabase', (next, stuff...)->
+    done = this.async()
+
+    r.connect config.rethinkdb, (err, conn) ->
+      if err
+        throw "\nBuckets could not connect to RethinkDB :/\n".magenta + "See the " + "README.md".bold + " for more info on installing RethinkDB and check your settings at " + "server/config.coffee".bold + "."
+        exit
+      else
+        console.log "Successfully connected to the database.\n"
+        conn.close()
+        done()
       
   grunt.loadNpmTasks 'grunt-bower-task'
   grunt.loadNpmTasks 'grunt-browserify'

  grunt.registerTask 'build', ['copy', 'bower', 'uglify:vendor', 'build-scripts', 'build-style', 'modernizr']
  grunt.registerTask 'minify', ['build', 'uglify:app', 'cssmin']

  grunt.registerTask 'dev', ['build', 'express:dev', 'watch']

  # grunt.registerTask 'serve', ['minify', 'express:dev', 'watch'] # Find way to do without watch?
r = require 'rethinkdb'
config = require './server/config'

module.exports = (grunt) ->

  grunt.initConfig
