Skip to content

Commit

Permalink
Merge pull request octobercms#2497 from gpasztor87/develop
Browse files Browse the repository at this point in the history
Allow combine scss files from command.
  • Loading branch information
daftspunk authored Nov 16, 2016
2 parents 1a41f63 + cf1fda7 commit 381ae47
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
42 changes: 24 additions & 18 deletions modules/system/classes/CombineAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function combineToFile($assets = [], $destination)

/**
* Returns the combined contents from a prepared cache identifier.
* @param string $cacheKey Cache identifier.
* @return string Combined file contents.
*/
public function getContents($cacheKey)
Expand Down Expand Up @@ -212,7 +213,7 @@ public function getContents($cacheKey)
/**
* Prepares an array of assets by normalizing the collection
* and processing aliases.
* @param $assets array
* @param array $assets
* @return array
*/
protected function prepareAssets(array $assets)
Expand Down Expand Up @@ -284,8 +285,8 @@ protected function prepareAssets(array $assets)
/**
* Combines asset file references of a single type to produce
* a URL reference to the combined contents.
* @var array List of asset files.
* @var string File extension, used for aesthetic purposes only.
* @param array $assets List of asset files.
* @param string $localPath File extension, used for aesthetic purposes only.
* @return string URL to contents.
*/
protected function prepareRequest(array $assets, $localPath = null)
Expand Down Expand Up @@ -335,6 +336,8 @@ protected function prepareRequest(array $assets, $localPath = null)

/**
* Returns the combined contents from a prepared cache identifier.
* @param array $assets List of asset files.
* @param string $rewritePath
* @return string Combined file contents.
*/
protected function prepareCombiner(array $assets, $rewritePath = null)
Expand Down Expand Up @@ -394,6 +397,7 @@ protected function setHashOnCombinerFilters($hash)

/**
* Returns a deep hash on filters that support it.
* @param array $assets List of asset files.
* @return void
*/
protected function getDeepHashFromAssets($assets)
Expand Down Expand Up @@ -442,6 +446,7 @@ protected function getCombinedUrl($outputFilename = 'undefined.css')
* /combine returns combine/
* /index.php/combine returns index-php/combine/
*
* @param string|null $path
* @return string The new target path
*/
protected function getTargetPath($path = null)
Expand Down Expand Up @@ -488,7 +493,7 @@ public static function registerCallback(callable $callback)
* Register a filter to apply to the combining process.
* @param string|array $extension Extension name. Eg: css
* @param object $filter Collection of files to combine.
* @return Self
* @return self
*/
public function registerFilter($extension, $filter)
{
Expand All @@ -515,7 +520,7 @@ public function registerFilter($extension, $filter)
/**
* Clears any registered filters.
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function resetFilters($extension = null)
{
Expand All @@ -532,7 +537,7 @@ public function resetFilters($extension = null)
/**
* Returns filters.
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function getFilters($extension = null)
{
Expand All @@ -556,7 +561,7 @@ public function getFilters($extension = null)
* @param string $alias Alias name. Eg: framework
* @param object $filter Collection of files to combine
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function registerBundle($files, $destination = null, $extension = null)
{
Expand All @@ -575,11 +580,12 @@ public function registerBundle($files, $destination = null, $extension = null)
if ($destination === null) {
$file = File::name($firstFile);
$path = dirname($firstFile);
$preprocessors = array_except(self::$cssExtensions, 'css');

if ($extension == 'less') {
if (in_array($extension, $preprocessors)) {
$cssPath = $path.'/../css';
if (
strtolower(basename($path)) == 'less' &&
in_array(strtolower(basename($path)), $preprocessors) &&
File::isDirectory(File::symbolizePath($cssPath))
) {
$path = $cssPath;
Expand All @@ -599,7 +605,7 @@ public function registerBundle($files, $destination = null, $extension = null)
/**
* Returns bundles.
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function getBundles($extension = null)
{
Expand All @@ -623,7 +629,7 @@ public function getBundles($extension = null)
* @param string $alias Alias name. Eg: framework
* @param string $file Path to file to use for alias
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function registerAlias($alias, $file, $extension = null)
{
Expand All @@ -645,7 +651,7 @@ public function registerAlias($alias, $file, $extension = null)
/**
* Clears any registered aliases.
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function resetAliases($extension = null)
{
Expand All @@ -662,7 +668,7 @@ public function resetAliases($extension = null)
/**
* Returns aliases.
* @param string $extension Extension name. Eg: css
* @return Self
* @return self
*/
public function getAliases($extension = null)
{
Expand All @@ -684,8 +690,8 @@ public function getAliases($extension = null)
/**
* Stores information about a asset collection against
* a cache identifier.
* @var string Cache identifier.
* @var array List of asset files.
* @param string $cacheKey Cache identifier.
* @param array $cacheInfo List of asset files.
* @return bool Successful
*/
protected function putCache($cacheKey, array $cacheInfo)
Expand All @@ -703,7 +709,7 @@ protected function putCache($cacheKey, array $cacheInfo)

/**
* Look up information about a cache identifier.
* @var string Cache identifier
* @param string $cacheKey Cache identifier
* @return array Cache information
*/
protected function getCache($cacheKey)
Expand All @@ -719,7 +725,7 @@ protected function getCache($cacheKey)

/**
* Builds a unique string based on assets
* @var array Asset files
* @param array $assets Asset files
* @return string Unique identifier
*/
protected function getCacheKey(array $assets)
Expand Down Expand Up @@ -765,7 +771,7 @@ public static function resetCache()
/**
* Adds a cache identifier to the index store used for
* performing a reset of the cache.
* @var string Cache identifier
* @param string $cacheKey Cache identifier
* @return bool Returns false if identifier is already in store
*/
protected function putCacheIndex($cacheKey)
Expand Down
6 changes: 6 additions & 0 deletions modules/system/console/OctoberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* - compile assets: Compile registered Language, LESS and JS files.
* - compile js: Compile registered JS files only.
* - compile less: Compile registered LESS files only.
* - compile scss: Compile registered SCSS files only.
* - compile lang: Compile registered Language files only.
*
*/
Expand Down Expand Up @@ -96,6 +97,11 @@ protected function utilCompileLess()
$this->utilCompileAssets('less');
}

protected function utilCompileScss()
{
$this->utilCompileAssets('scss');
}

protected function utilCompileAssets($type = null)
{
$this->comment('Compiling registered asset bundles...');
Expand Down

0 comments on commit 381ae47

Please sign in to comment.