Passed
Push — master ( f01d00...2f7647 )
by Nicolaas
03:27
created

CreateClientFolder::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * This task adds a legacy branch to the git repo of the original to act as a backup/legacy version for
9
 * holding a version of the module before it was changed
10
 */
11
class CreateClientFolder extends Task
12
{
13
    protected $taskStep = 's30';
14
15
    public function getTitle()
16
    {
17
        return 'Move front-end stuff to a client folder';
18
    }
19
20
    public function getDescription()
21
    {
22
        return '
23
            Takes the javascript, css, and images folders and puts them in a newly created client folder.';
24
    }
25
26
    /**
27
     * [runActualTask description]
28
     * @param  array  $params not currently used for this task
29
     * @return [type]         [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
30
     */
31
    public function runActualTask($params = [])
32
    {
33
        foreach ($this->mu()->getExistingModuleDirLocations() as $moduleDir) {
34
            $newClientFolder = $moduleDir . '/client/ ';
35
            $this->mu()->execMe(
36
                $moduleDir,
37
                'mkdir -v ' . $newClientFolder,
38
                'Creating new client folder: ' . $newClientFolder,
39
                false
40
            );
41
            $foldersToMoveName = [
42
                'javascript',
43
                'js',
44
                'images',
45
                'img',
46
                'css',
47
            ];
48
            foreach ($foldersToMoveName as $folderToMoveName) {
49
                $folderToMove = $moduleDir . '/' . $folderToMoveName . '/ ';
50
                $this->mu()->execMe(
51
                    $moduleDir,
52
                    'if test -d ' . $folderToMove . '; then mv -vn ' . $folderToMove . ' ' . $newClientFolder . '; fi;',
53
                    'Moving ' . $folderToMove . ' to ' . $newClientFolder . ' -v is verbose, -n is only if does not exists already.',
54
                    false
55
                );
56
            }
57
        }
58
    }
59
60
    protected function hasCommitAndPush()
61
    {
62
        return true;
63
    }
64
}
65