forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulp.php
More file actions
84 lines (69 loc) · 2.25 KB
/
Copy pathGulp.php
File metadata and controls
84 lines (69 loc) · 2.25 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
81
82
83
84
<?php
namespace PHPCensor\Plugin;
use PHPCensor\Builder;
use PHPCensor\Model\Build;
use PHPCensor\Plugin;
/**
* Gulp Plugin - Provides access to gulp functionality.
*
* @author Dirk Heilig <dirk@heilig-online.com>
*/
class Gulp extends Plugin
{
protected $task;
protected $preferDist;
protected $gulpfile;
/**
* @return string
*/
public static function pluginName()
{
return 'gulp';
}
/**
* {@inheritdoc}
*/
public function __construct(Builder $builder, Build $build, array $options = [])
{
parent::__construct($builder, $build, $options);
$this->task = null;
// deprecated compatibility option
if (isset($options['gulp']) && !isset($options['executable'])) {
$options['executable'] = $options['gulp'];
}
/** @deprecated Option "gulp" is deprecated and will be deleted in version 2.0. Use the option "binary_path" and "binary_name" instead. */
if (isset($options['gulp'])) {
$this->builder->logWarning(
'[DEPRECATED] Option "gulp" is deprecated and will be deleted in version 2.0. Use the option "binary_path" and "binary_name" instead.'
);
$this->executable = $options['gulp'];
} else {
$this->executable = $this->findBinary('gulp');
}
$this->gulpfile = 'gulpfile.js';
if (isset($options['task'])) {
$this->task = $options['task'];
}
if (isset($options['gulpfile'])) {
$this->gulpfile = $options['gulpfile'];
}
}
/**
* Executes gulp and runs a specified command (e.g. install / update)
*/
public function execute()
{
// if npm does not work, we cannot use gulp, so we return false
$cmd = 'cd %s && npm install';
if (!$this->builder->executeCommand($cmd, $this->directory)) {
return false;
}
// build the gulp command
$cmd = 'cd %s && ' . $this->executable;
$cmd .= ' --no-color';
$cmd .= ' --gulpfile %s';
$cmd .= ' %s'; // the task that will be executed
// and execute it
return $this->builder->executeCommand($cmd, $this->directory, $this->gulpfile, $this->task);
}
}