import css from 'steal/css';
import lessEngine from 'less';

export var instantiate = css.instantiate;

export function translate(load) {
	var pathParts = (load.address+'').split('/');
		pathParts[pathParts.length - 1] = ''; // Remove filename

	var paths = [];
	if (typeof window !== 'undefined') {
		var pathParts = (load.address+'').split('/');
		pathParts[pathParts.length - 1] = ''; // Remove filename
		paths = [pathParts.join('/')];
	}
	return new Promise(function(resolve, reject){
		new (lessEngine.Parser)({
	        optimization: lessEngine.optimization,
	        paths: [pathParts.join('/')]
	    }).parse(load.source, function (e, root) {
			if(e){
				reject(e);
			} else {
				resolve(root.toCSS());
			}
		});
	});

};

export var buildType = "css";
var css = require("steal/css");
var lessEngine = require("less");

exports.instantiate = css.instantiate;

exports.translate = function(load) {
	var pathParts = (load.address+'').split('/');
		pathParts[pathParts.length - 1] = ''; // Remove filename

	var paths = [];
	if (typeof window !== 'undefined') {
		var pathParts = (load.address+'').split('/');
		pathParts[pathParts.length - 1] = ''; // Remove filename
		paths = [pathParts.join('/')];
	}
	return new Promise(function(resolve, reject){
		new (lessEngine.Parser)({
	        optimization: lessEngine.optimization,
	        paths: [pathParts.join('/')]
	    }).parse(load.source, function (e, root) {
			if(e){
				reject(e);
			} else {
				resolve(root.toCSS());
			}
		});
	});
};

exports.buildType = "css";

Convert steal plugin to use CommonJS
Convert steal plugin to use CommonJS

Previously was using ES6 which won't work in Phantom due to Traceur
using ES5 features that Phantom 1.x doesn't support. This switches the
plugin to use CommonJS, matching what css.js uses.
