-{spawn} = require 'child_process'
+{spawn, exec} = require 'child_process'
 {print} = require 'util'
 Q = require 'q'
 

            'specs/support/**/*.coffee'
            'specs/units/**/*.coffee'
          ]

    uglify:
      all:
        files:
          'lib/agt.min.js': ['lib/agt.js']

    watch:
      scripts:
        files: ['src/**/*.coffee', 'specs/**/*.coffee']
        tasks: ['coffee', 'uglify', 'test', 'biscotto']
        options:
          livereload: true
          livereloadOnError: true

      config:
        files: ['Gruntfile.coffee']

        title: 'Biscotto Documentation'
        message: 'Documentation generated'

  ####    ########    ###     ######  ##    ##  ######
  ####       ##      ## ##   ##    ## ##   ##  ##    ## 
  ####       ##     ##   ##  ##       ##  ##   ##
  ####       ##    ##     ##  ######  #####     ######
  ####       ##    #########       ## ##  ##         ##
  ####       ##    ##     ## ##    ## ##   ##  ##    ##
  ####       ##    ##     ##  ######  ##    ##  ######

  grunt.loadNpmTasks('grunt-contrib-uglify')
  grunt.loadNpmTasks('grunt-contrib-watch')
  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-growl')

  grunt.registerTask 'extend:biscotto', 'Generates the documentation', ->
    done = @async()
    exec 'cat lib/agt.min.js doc/assets/customs.js >> doc/assets/biscotto.js', (err, stdin, stderr) ->
      console.log stdin
      console.log stderr
      grunt.task.run 'growl:biscotto_success'
      done()

  grunt.registerTask 'biscotto', 'Generates the documentation', ->
    done = @async()
    run('biscotto src')
    .then ->
      done()
    .fail ->
      done()
