LarrockAssetsCommand::handle()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 4
eloc 13
c 2
b 1
f 1
nc 4
nop 0
dl 0
loc 20
rs 9.8333
1
<?php
2
3
namespace Larrock\Core\Commands;
4
5
use Illuminate\Console\Command;
6
7
class LarrockAssetsCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'larrock:assets';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Install assets (via bower)';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function handle()
29
    {
30
        $this->line('=== Install assets via bower ===');
31
32
        $libraries = ['fancybox', 'jquery-validation', 'jquery.cookie', 'fileapi', 'jquery.spinner', 'microplugin', 'pickadate',
33
            'selectize', 'sifter', 'tinymce', 'uikit#2.27.5', ];
34
35
        foreach ($libraries as $library) {
36
            if (! \File::exists(base_path('public_html/_assets/bower_components/'.$library))) {
37
                echo shell_exec('bower install '.$library);
38
                if (\File::exists(base_path('public_html/_assets/bower_components/'.$library))) {
39
                    $this->info('=== '.$library.' successfully installed ===');
40
                } else {
41
                    $this->alert('=== ERROR! '.$library.' not installed ===');
42
                }
43
            } else {
44
                $this->info('=== '.$library.' already installed ===');
45
            }
46
        }
47
        $this->info('=== END of assets ===');
48
    }
49
}
50