Skip to content

RC1 - beta #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
var/
vendor/
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: php
#
#sudo: false
#
#cache:
# directories:
# - $HOME/.composer/cache/files
#
#matrix:
# include:
## - php: 5.6
# - php: 7.0
# - php: hhvm
#
#before_script:
# - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
# - composer update $COMPOSER_FLAGS
#
#script: phpunit --coverage-text --coverage-clover=coverage.clover
#
#after_script:
# - wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 learn-symfony
Copyright (c) 2016 Eugene Matvejev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
46 changes: 46 additions & 0 deletions ScriptHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace EM\CssCompiler\Handler;

use Composer\Script\Event;
use EM\CssCompiler\Processor\Processor;

class ScriptHandler
{
public static function compileCSS(Event $event)
{
$extras = $event->getComposer()->getPackage()->getExtra();

if (!isset($extras['css-compiler'])) {
throw new \InvalidArgumentException('The parameter handler needs to be configured through the extra.css-compiler setting.');
}

$configs = $extras['css-compiler'];

if (!is_array($configs)) {
throw new \InvalidArgumentException('The extra.css-compiler setting must be an array of a configuration objects.');
}

if (array_keys($configs) !== range(0, count($configs) - 1)) {
$configs = [$configs];
}

$processor = new Processor($event->getIO());

exec('rm -rf ' . __DIR__ . '/var/*');

foreach ($configs as $config) {
if (!is_array($config)) {
throw new \InvalidArgumentException('The extra.css-compiler should contain only configuration objects.');
}

foreach ($config['input'] as $item => $value) {
$processor->attachFiles(__DIR__ . "/{$value}", __DIR__ . "/{$config['output']}");
}

$processor->processFiles($config['format'] ?? 'compact');
}

$processor->saveOutput();
}
}
71 changes: 71 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "eugenematvejev/css_compiler",
"description": "compiles css assets from sass or less on composer events",
"type": "lib",
"license": "MIT",
"authors": [
{
"name": "Eugene Matvejev",
"email": "eugene.matvejev@gmail.com"
}
],
"autoload": {
"psr-4": {
"EM\\CssCompiler\\Handler\\": "",
"EM\\CssCompiler\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"EM\\Tests\\CssCompiler\\": "tests/"
}
},
"require": {
"php": ">= 7.0.4",
"leafo/lessphp": "^0.5",
"leafo/scssphp": "0.6.3 as dev-master",
"leafo/scssphp-compass": "dev-master"
},
"require-dev": {
"composer/composer": "^1.1",
"phpunit/phpunit": "^5.4"
},
"minimum-stability": "dev",
"scripts": {
"post-update-cmd": "@custom-events",
"post-install-cmd": "@custom-events",
"custom-events": [
"EM\\CssCompiler\\Handler\\ScriptHandler::compileCSS"
]
},
"config": {
"bin-dir": "bin/"
},
"extra": {
"css-compiler": [
{
"format": "compact",
"force": true,
"input": [
"tests/shared-fixtures/scss"
],
"output": "var/cache/assets/scss.css"
},
{
"format": "compact",
"force": true,
"input": [
"tests/shared-fixtures/sass"
],
"output": "var/cache/assets/sass.css"
},
{
"format": "compact",
"input": [
"tests/shared-fixtures/compass/app.scss"
],
"output": "var/cache/assets/compass.css"
}
]
}
}
Loading