More composer stuff, updated compile / minify logic

Now using composer installed apps for less and scss files.
This commit is contained in:
Joshua Sherman 2014-01-02 22:39:19 -05:00
parent bfa35794b5
commit 17752f71b3
4 changed files with 113 additions and 41 deletions

View file

@ -150,37 +150,33 @@ class Dynamic extends Object
{
$reference = $original_reference;
// @todo LESS and SASS compiling should happen regardless of minification
if ($this->config->pickles['minify'] === true)
// Compiles LESS & SASS to CSS before minifying
if ($less || $sass)
{
// Compiles LESS & SASS to CSS before minifying
if ($less || $sass)
$compiled_filename = str_replace('.min', '', $minified_filename);
require_once $this->config->pickles['path'] . '.composer/autoload.php';
if ($less)
{
$compiled_filename = str_replace('.min', '', $minified_filename);
$less = new lessc();
$less->compileFile($original_filename, $compiled_filename);
}
elseif ($sass)
{
$scss = new scssc();
if ($less)
{
// I couldn't get getenv() to give me the PATH value... so yeah, there's that.
exec('echo $PATH', $path);
putenv('PATH=' . $path[0] . PATH_SEPARATOR . '/usr/local/bin');
$command = 'lessc ' . $original_filename . ' > ' . $compiled_filename;
}
elseif ($sass)
{
$command = 'sass ' . $original_filename . ':' . $compiled_filename;
}
exec($command, $output, $return);
if ($return !== 0)
{
throw new Exception('There was an error executing `' . $command . '` it returned exit code ' . $return);
}
$original_filename = $compiled_filename;
file_put_contents(
$compiled_filename,
$scss->compile(file_get_contents($original_filename))
);
}
$original_filename = $compiled_filename;
}
if ($this->config->pickles['minify'] === true)
{
// Minifies CSS with a few basic character replacements.
$stylesheet = file_get_contents($original_filename);
$stylesheet = str_replace(array("\t", "\n", ', ', ' {', ': ', ';}', '{ ', '; '), array('', '', ',', '{', ':', '}', '{', ';'), $stylesheet);

View file

@ -3,6 +3,8 @@
"vendor-dir": ".composer"
},
"require": {
"mikey179/vfsStream": "1.2.0"
"mikey179/vfsStream": "1.2.0",
"leafo/lessphp": "0.4.0",
"leafo/scssphp": "0.0.9"
}
}

89
composer.lock generated
View file

@ -3,8 +3,95 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "43a9d6fa1fc1d241f48c50222da238c8",
"hash": "9a22b4eaac6e820d8603b95b9f21c33a",
"packages": [
{
"name": "leafo/lessphp",
"version": "v0.4.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/lessphp.git",
"reference": "51f3f06f0fe78a722dabfd14578444bdd078d9de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/51f3f06f0fe78a722dabfd14578444bdd078d9de",
"reference": "51f3f06f0fe78a722dabfd14578444bdd078d9de",
"shasum": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"classmap": [
"lessc.inc.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/",
"time": "2013-08-09 17:09:19"
},
{
"name": "leafo/scssphp",
"version": "v0.0.9",
"source": {
"type": "git",
"url": "https://github.com/leafo/scssphp.git",
"reference": "a06d702ebf9fabb22542bbb27cc12a905813bb6d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/scssphp/zipball/a06d702ebf9fabb22542bbb27cc12a905813bb6d",
"reference": "a06d702ebf9fabb22542bbb27cc12a905813bb6d",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"php": ">=5.3.0",
"phpunit/phpunit": "3.7.*"
},
"bin": [
"pscss"
],
"type": "library",
"autoload": {
"classmap": [
"scss.inc.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://leafo.net/scssphp/",
"time": "2013-12-23 23:28:02"
},
{
"name": "mikey179/vfsStream",
"version": "v1.2.0",

View file

@ -104,19 +104,6 @@ CSS;
$this->dynamic->css('/css/invalid');
}
// TODO May not be able to do these two as it would require lessc and sass to not be installed
// TODO Good chance will also fail on Travis due to missing dependencies, will need to work through that
// TODO will probably want to move to the composer available versions of these
public function testCSSCommandErrorLESS()
{
}
public function testCSSCommandErrorSASS()
{
}
public function testCSSWithoutMinify()
{
$config = Config::getInstance();