 
     fs.writeFile filename, code, (err) =>
       return callback err if err
-      @components[name] =
+      changes = {}
+      changes[name] =
         language: language
         command: componentCommandForFile @options.config, filename
+      @_updateComponents changes
       return callback null
 
   componentCommand: (component, role, iips={}) ->

fs = require 'fs'
path = require 'path'
debug = require('debug')('msgflo:library')

common = require './common'



    @components = {} # "name" -> { command: "", language: ''|null }.  lazy-loaded using load()

  _updateComponents: (components) ->
    names = Object.keys components
    for name, comp of components
      @components[name] = comp
    @emit 'components-changed', names, @components

  load: (callback) ->
    componentsFromDirectory @options.componentdir, @options.config, (err, components) =>
      return callback err if err
      @_updateComponents components
      @_updateComponents componentsFromConfig(@options.config)
      return callback null

  getSource: (name, callback) ->
