 
   # Public: Creates a task.
   #
-  # * taskPath:
-  #   The path to the Coffeescript/Javascript file that exports a single
-  #   function to execute.
+  # taskPath - The {String} path to the CoffeeScript/JavaScript file that
+  #            exports a single {Function} to execute.
   constructor: (taskPath) ->
     coffeeCacheRequire = "require('#{require.resolve('./coffee-cache')}').register();"
     coffeeScriptRequire = "require('#{require.resolve('coffee-script')}').register();"


  # Public: Starts the task.
  #
  # * args:
  #   The Array of arguments to pass to the function exported by the script. If
  #   the last argument is a function, its removed from the array and called
  #   upon completion (and replaces the complete function on the task instance).
  start: (args...) ->
    throw new Error("Cannot start terminated process") unless @childProcess?

    @handleEvents()
    @callback = args.pop() if _.isFunction(args[args.length - 1])
    @send({event: 'start', args})

  # Public: Send message to the task.
  #
  # * message:
  #   The message to send
  send: (message) ->
    throw new Error("Cannot send message to terminated process") unless @childProcess?
    @childProcess.send(message)


  # Public: A helper method to easily launch and run a task once.
  #
  # taskPath - The {String} path to the CoffeeScript/JavaScript file which
  #            exports a single {Function} to execute.
  # args     - The arguments to pass to the exported function.
  @once: (taskPath, args...) ->
    task = new Task(taskPath)
    task.once 'task:completed', -> task.terminate()
