Skip to content

Commit

Permalink
feat: added command minify-js and minify-css
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Apr 13, 2023
1 parent 94272f1 commit abd853f
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/Commands/MinifyCss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* This file is part of PHPDevsr/Minifyku.
*
* (c) 2023 Denny Septian Panggabean <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace PHPDevsr\Minifyku\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Config\Services;

/**
* Minify CSS assets
*
* @codeCoverageIgnore
*/
class MinifyCss extends BaseCommand
{
protected $group = 'Minifyku';
protected $name = 'minifyku:minify-css';
protected $description = 'Minify all assets CSS.';

public function __construct()
{
}

/**
* Prepare assets to use on website
*/
public function run(array $params)
{
$benchmark = Services::timer();
$minify = service('minifyku');

$benchmark->start('Minifyku');

$result = $minify->deploy('css');

$benchmark->stop('Minifyku');

if (! $result) {
CLI::error($minify->getError());

exit;
}

$time = $benchmark->getElapsedTime('Minifyku');

CLI::write('[+] Finished in: ' . CLI::color($time . 's.', 'green'));
CLI::write('[+] All files CSS were successfully generated.', 'green');
}
}
58 changes: 58 additions & 0 deletions src/Commands/MinifyJs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* This file is part of PHPDevsr/Minifyku.
*
* (c) 2023 Denny Septian Panggabean <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace PHPDevsr\Minifyku\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Config\Services;

/**
* Minify JS assets
*
* @codeCoverageIgnore
*/
class MinifyJs extends BaseCommand
{
protected $group = 'Minifyku';
protected $name = 'minifyku:minify-js';
protected $description = 'Minify all assets JS.';

public function __construct()
{
}

/**
* Prepare assets to use on website
*/
public function run(array $params)
{
$benchmark = Services::timer();
$minify = service('minifyku');

$benchmark->start('Minifyku');

$result = $minify->deploy('js');

$benchmark->stop('Minifyku');

if (! $result) {
CLI::error($minify->getError());

exit;
}

$time = $benchmark->getElapsedTime('Minifyku');

CLI::write('[+] Finished in: ' . CLI::color($time . 's.', 'green'));
CLI::write('[+] All files JS were successfully generated.', 'green');
}
}

0 comments on commit abd853f

Please sign in to comment.