 
 {CompositeDisposable} = require 'atom'
 
-class Comb
+module.exports =
+  #
+  # CONFIG
+  #
 
   config:
     shouldNotSearchConfig:

    @subscriptions.dispose()

  comb: ->
    @showNotifications = atom.config.get('css-comb.showNotifications') && atom.notifications && atom.notifications.addInfo

    filePath = atom.workspace.getActivePaneItem().getPath()

    if !atom.config.get('css-comb.shouldNotSearchConfig')
      configPath = path.join(path.dirname(filePath), '.csscomb.json')
      configPath = CSScomb.getCustomConfigPath(configPath)

    if configPath
      @processFile filePath, require(configPath)
    else
      configPath = atom.config.get('css-comb.customConfig')

      if configPath && fs.existsSync(configPath)
        @processFile filePath, require(configPath)
      else
        @processFile filePath, CSScomb.getConfig(atom.config.get('css-comb.predef'))

  processFile: (filePath, config) ->
    comb = new CSScomb(config)
    comb.processFile(filePath)

    if @showNotifications
      atom.notifications.addInfo('File processed by csscomb')

module.exports = new Comb

      type: 'boolean'
      default: true

  #
  # PROPS
  #

  subscriptions: null

  #
  # PUBLIC
  #

  activate: (state) ->
    # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
