 
       launch:
         command: ->
-          appname = grunt.config.get 'APP_NAME'
-          console.log appname
           appid = grunt.config.get 'APP_ID'
+
+          if (!appid)
+            return grunt.task.clearQueue().run(['shell:getid', 'shell:launch'])
+
+          appname = @config.get 'APP_NAME'
+
           if appid
             "webtizen -r -i #{appid}.#{appname}"
 
       uninstall:
         command: ->
-          appid = grunt.config.get 'APP_ID'
+          appid = @config.get 'APP_ID'
           if appid
             "webtizen -u -i #{appid}"
 
       debug:
         command: ->
-          appid = grunt.config.get 'APP_ID'
+          appid = @config.get 'APP_ID'
           if appid
             "webtizen -d -i #{appid}"
 

        options:
          callback: (err, stdout, stderr, cb) ->
            return if grunt.config.get 'APP_ID'
            lines = stdout.split(/\n/).slice(3, -2)
            ids = lines.map (l) ->
              return l.split(/\s+/).slice(-1)[0]


      js:
        files: ['<%= JS_DIR %>**/*.js', '!<%= JS_LIBS_DIR %>**/*.js']
        tasks: ['copy:devjs']

    shell:
      package:
