     return {} unless slug and fs.existsSync(slug)
     JSON.parse(fs.readFileSync(slug, 'utf-8'))
 
-  createPackage: (name, config) ->
+  createPackage: (name, config, argv) ->
     pkg = new Package(name, config)
 
   buildTargets: (targets = []) ->

# ------- Commandline arguments

argv = optimist.usage([
  '  usage: hem COMMAND',
  '    server  start a dynamic development server',
  '    build   serialize application to disk',
  '    watch   build & watch disk for changes'
  '    test    build and run tests'
  '    clean   clean compiled files'
].join("\n"))
.alias('p', 'port')
.alias('d', 'debug')
.alias('t', 'test')
.alias('s', 'slug')
.alias('b', 'browser')
.argv

# ------- Global Functions


          console.log('child process exited with code ' + code)

  clean: () ->
    targets = argv.targets
    cleanAll = targets.length is 0
    pkg.unlink() for pkg in @packages when pkg.name in targets or cleanAll

  build: ->
    @clean()
    @buildTargets(argv.targets)

  watch: ->
    targets = argv.targets
    @buildTargets(targets)
    # also run testacular tests if -t is passed in the command line
    @startTestacular(targets, false) if argv.test
    # begin watching package targets
    watchAll = targets.length is 0
    pkg.watch() for pkg in @packages when pkg.name in targets or watchAll

  test: ->
    @buildTargets(argv.targets)
    @startTestacular(argv.targets)

  exec: (command = argv.command) ->
    return help() unless @[command]
    # TODO: make sure argv.targets exist before proceeding??
    switch command
      when 'build'  then console.log 'Build application'
      when 'watch'  then console.log 'Watching application'
