       partial  : "Do you still want to continue?"
       cssClass : "run-warning"
 
-  @appendHeadElement = (type, {identifier, url, callback}, force)->
+  @appendHeadElement = Promise.promisify (type, {identifier, url, force}, callback = (->)) ->
 
     identifier = identifier.replace /\./g, '_'
     domId      = "internal-#{type}-#{identifier}"

        domId, tagName, attributes, bind, load
      }).getElement()

  @destroyScriptElement = (type, identifier)->
    (document.getElementById "internal-#{type}-#{identifier}")?.remove()

  @appendHeadElements = (options, callback)->

    {items, identifier} = options

    stack = []
    items.forEach ({url, type}, index)->
      stack.push (cb)->
        KodingAppsController.appendHeadElement type, {
          identifier : "#{identifier}-#{index}"
          callback   : cb
          url
        }
        KD.utils.defer cb  if type is 'style'

    async.series stack, callback


  # #
  # MAKE NEW APP


    {vmController} = KD.singletons

    vmController.run
      method    : "app.skeleton"
      withArgs  :
        type    : "blank"
        appPath : appPath

    .then ->
      indexFile = FSHelper.createFileFromPath "#{appPath}/index.coffee"
      indexFile.fetchContents().then (content) ->
        content = content.replace(/\%\%APPNAME\%\%/g, APPNAME)
                         .replace(/\%\%appname\%\%/g, appname)
                         .replace(/\%\%AUTHOR\%\%/g , KD.nick())
        indexFile.save content

    .then ->
      styleFile = FSHelper.createFileFromPath "#{appPath}/resources/style.css"
      styleFile.fetchContents().then (content) ->
        content = content.replace(/\%\%appname\%\%/g, appname)
        styleFile.save content

    .then ->
      FSHelper.createFileFromPath("#{appPath}/manifest.json")
              .save manifestStr
    .then ->
      FSHelper.createFileFromPath("#{appPath}/ChangeLog")
              .save changeLogStr

    .then ->
      return { appPath }

    .catch (err) ->
      warn err

    .nodeify callback

  @getAppInfoFromPath = (path, showWarning = no)->

