'use strict';

var postcss = require('postcss')
var loop = require('simple-loop')

exports.name = 'postcss'
exports.inputFormats = ['postcss', 'css']
exports.outputFormat = 'css'

function sanitizePlugins(pluginsToLoad) {
  var plugins = []
  loop(pluginsToLoad, function (item, i) {
    var plugin = null
    switch (typeof i) {
      case 'number':
        if (typeof item == 'string') {
          plugin = require(item)
        }
        else {
          plugin = item
        }
        break
      case 'object':
        plugin = i
        break
      case 'string':
        plugin = require(i)(item)
        break
      default:
        plugin = i
        break
    }
    if (plugin) {
      plugins.push(plugin)
    }
  })
  return plugins
}

exports.render = function (str, options) {
  var plugins = sanitizePlugins(options.plugins || [])
  return postcss(plugins).process(str, options).css
}

exports.renderAsync = function (str, options) {
  return new Promise(function (resolve, reject) {
    var plugins = sanitizePlugins(options.plugins || [])
    postcss(plugins).process(str, options).then(function (result) {
      // TODO: Add result.map to "dependencies".
      resolve(result.css)
    }).catch(reject)
  })
}

@@ -947,60 +947,8 @@
 ) %7B%0A
-  return new Promise(function (resolve, reject) %7B%0A  
   va
@@ -1000,17 +1000,22 @@
 %7C %5B%5D)%0A  
- 
+return
  postcss
@@ -1075,18 +1075,16 @@
 ) %7B%0A    
- 
- 
 // TODO:
@@ -1126,50 +1126,25 @@
     
-  resolve(result.css)%0A    %7D).catch(reject)
+return result.css
 %0A  %7D

Simplify renderAsync