   onConfig: (device) =>
     @setOptions device.options
 
-  setOptions: (@options={}) =>
+  setOptions: (options={}) =>
+    @options = options
+    projectDirName = path.basename @options.gitRepo, '.git'
+    @dir = path.join @tmpDir, projectDirName
+
   setUuid: (@uuid={}) =>
 
   startCommand: (callback=->) =>

OPTIONS_SCHEMA =
  type: 'object'
  properties:
    setup:
      type: 'string'
      required: true

    @messageSchema = MESSAGE_SCHEMA
    @optionsSchema = OPTIONS_SCHEMA
    @commands = {start: @startCommand, stop: @stopCommand}
    @tmpDir = path.join __dirname, 'tmp'

  onMessage: (message) =>
    payload = message.payload;
    command = @commands[payload.command]
    return unless command?
    command (error, stdout) =>
      if  error?
        @emit 'error', error
        @emit 'message', error: error
        return
