Completed
Push — master ( c8ce79...6ffbf3 )
by Adam
03:48 queued 12s
created

Gulp::getDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace Genesis\Commands\Assets;
5
6
7
use Genesis\Commands;
8
9
/**
10
 * @author Adam Bisek <[email protected]>
11
 */
12
class Gulp extends Commands\Command
13
{
14
15
	private $gulpfile = 'gulpfile.js';
16
17
	private $directory;
18
19
20
	/**
21
	 * @return string
22
	 */
23 1
	public function getGulpfile()
24
	{
25 1
		return $this->gulpfile;
26
	}
27
28
29
	/**
30
	 * @param string $gulpfile
31
	 */
32 1
	public function setGulpfile($gulpfile)
33
	{
34 1
		$this->gulpfile = $gulpfile;
35 1
	}
36
37
38
	/**
39
	 * @return string
40
	 */
41 1
	public function getDirectory()
42
	{
43 1
		return $this->directory;
44
	}
45
46
47
	/**
48
	 * @param string $directory
49
	 */
50 1
	public function setDirectory($directory)
51
	{
52 1
		$this->directory = $directory;
53 1
	}
54
55
56 1
	public function execute($gulpCommand = NULL)
57
	{
58 1
		$path = $this->directory . DIRECTORY_SEPARATOR . $this->gulpfile;
59 1
		if (!file_exists($path)) {
60
			$this->error(sprintf("Cannot find gulpfile '%s'.", $path));
61
		}
62
63 1
		$cmd = 'cd ' . escapeshellarg($this->directory) . ' && gulp ' . $gulpCommand;
64 1
		$command = new Commands\Exec();
65 1
		$command->setCommand($cmd);
66 1
		$result = $command->execute();
67 1
		if ($result->getResult() !== 0) {
68
			$this->error(sprintf("Gulp task '%s' in directory %s failed.", $gulpCommand, $this->directory));
69
		}
70 1
		return $result;
71
	}
72
73
}