 path = require 'path'
 
 _ = require 'underscore-plus'
+async = require 'async'
 CSON = require 'season'
 fs = require 'fs-plus'
 {Emitter} = require 'emissary'

  deactivate: ->
    @activationDeferred?.reject()
    @activationDeferred = null
    @unsubscribeFromActivationEvents()
    @deactivateResources()
    @deactivateConfig()

    @scopedProperties = []

  activate: ->
    unless @activationDeferred?
      @activationDeferred = Q.defer()
      @measure 'activateTime', =>
        @activateResources()
        if @metadata.activationEvents?
          @subscribeToActivationEvents()
        else
          @activateNow()

    @grammarsPromise.then(@scopedPropertiesPromise).then(@activationDeferred.promise)

  activateNow: ->
    try
