Completed
Pull Request — newinternal (#542)
by Simon
11:55 queued 02:00
created

RegenerateStylesheetsTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 2
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 18 4
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\ConsoleTasks;
10
11
use Exception;
12
use ScssPhp\ScssPhp\Compiler;
13
use Waca\Tasks\ConsoleTaskBase;
14
use Waca\WebRequest;
15
16
class RegenerateStylesheetsTask extends ConsoleTaskBase
17
{
18
    const RESOURCES_GENERATED = 'resources/generated';
19
20
    public function execute()
21
    {
22
        $scss = new Compiler();
23
        $scss->setImportPaths('resources/scss');
24
25
        if (!$this->getSiteConfiguration()->getDebuggingTraceEnabled()) {
26
            $scss->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Compressed');
27
            $scss->setSourceMap(Compiler::SOURCE_MAP_INLINE);
28
        }
29
30
        if (!is_dir(self::RESOURCES_GENERATED)) {
31
            mkdir(self::RESOURCES_GENERATED);
32
        }
33
34
        foreach (['bootstrap-main', 'bootstrap-alt'] as $file) {
35
            file_put_contents(
36
                self::RESOURCES_GENERATED . '/' . $file . '.css',
37
                $scss->compile('/*! Do not edit this auto-generated file! */ @import "' . $file . '";'));
38
        }
39
    }
40
}
41