 module.exports = (grunt) ->
 
   grunt.loadNpmTasks 'grunt-banner'
+  grunt.loadNpmTasks 'grunt-bumpup'
   grunt.loadNpmTasks 'grunt-contrib-clean'
   grunt.loadNpmTasks 'grunt-contrib-coffee'
   grunt.loadNpmTasks 'grunt-mocha-test'

    clean:
      build:
        options:
          no-write: true
        src: ['index.js*', 'lib/*']

    coffee:

    type = type || 'patch'
    grunt.task.run 'bumpup:' + type

  grunt.registerTask 'release:commit', [ 'git:add:package.json', 'git:commit:release', 'git:tag:release' ]

  grunt.registerTask 'release:patch', [ 'release:prep', 'release:bump:patch', 'release:commit' ]


  grunt.registerTask 'git:add', (file) ->
    res = runSimple "git add #{file}"


  grunt.registerTask 'git:commit:release', ->
    msg = grunt.config 'release.options.commitMessage'
  return runSimple "git commit -m '#{msg}'"

  grunt.registerTask 'git:isClean', ->
    res = runSilent 'git status -s'
    return unless res.output
    grunt.log.error 'Uncommitted changes'
    grunt.log.writelns res.output
  return false

  grunt.registerTask 'git:tag:release', ->
    tag = grunt.config 'release.options.tagName'
    msg = grunt.config 'release.options.tagMessage'
  return runSimple "git tag  #{tag} -m '#{msg}'"

  _semverSync = 'node_modules/semver-sync/bin/semver-sync'

  grunt.registerTask 'semver:isSynced', ->
    res = runSilent "#{_semverSync} --verify"
    return false unless res.code == 0
    if res.code == 0
      grunt.log.writeln res.output
    return
    grunt.error res.output
  return false


# release:
# bump, stage+commit+tag+push, publish
