-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulp.php
More file actions
80 lines (67 loc) · 1.78 KB
/
Copy pathGulp.php
File metadata and controls
80 lines (67 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
namespace PHPCensor\Plugins\Frontend;
use PHPCensor\Common\Build\BuildInterface;
use PHPCensor\Common\Plugin\Plugin;
/**
* Gulp Plugin - Provides access to gulp functionality.
*
* @package PHP Censor
* @subpackage Plugins
*
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
* @author Dirk Heilig <dirk@heilig-online.com>
*/
class Gulp extends Plugin
{
private string $task = '';
private string $gulpfile = 'gulpfile.js';
/**
* {@inheritDoc}
*/
public static function getName(): string
{
return 'gulp';
}
/**
* {@inheritDoc}
*/
public function execute(): bool
{
$executable = $this->commandExecutor->findBinary($this->binaryNames, $this->binaryPath);
// if npm does not work, we cannot use gulp, so we return false
$cmd = 'cd "%s" && npm install';
if (!$this->commandExecutor->executeCommand($cmd, $this->directory)) {
return false;
}
$cmd = 'cd "%s" && ' . $executable;
$cmd .= ' --no-color';
$cmd .= ' --gulpfile %s';
$cmd .= ' %s';
return $this->commandExecutor->executeCommand($cmd, $this->directory, $this->gulpfile, $this->task);
}
/**
* {@inheritDoc}
*/
public static function canExecute(string $stage, BuildInterface $build): bool
{
return true;
}
/**
* {@inheritDoc}
*/
protected function initPluginSettings(): void
{
$this->task = (string)$this->options->get('task', $this->task);
$this->gulpfile = (string)$this->options->get('gulpfile', $this->gulpfile);
}
/**
* {@inheritDoc}
*/
protected function getPluginDefaultBinaryNames(): array
{
return [
'gulp',
];
}
}