Completed
Push — master ( d3a073...5737c8 )
by Greg
02:21
created

src/Task/Npm/Base.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Robo\Task\Npm;
3
4
use Robo\Task\BaseTask;
5
use Robo\Exception\TaskException;
6
7
abstract class Base extends BaseTask
8
{
9
    use \Robo\Common\ExecOneCommand;
10
11
    /**
12
     * @var string
13
     */
14
    protected $command = '';
15
16
    /**
17
     * @var string[]
18
     */
19
    protected $opts = [];
20
21
    /**
22
     * @var string
23
     */
24
    protected $action = '';
25
26
    /**
27
     * adds `production` option to npm
28
     *
29
     * @return $this
30
     */
31
    public function noDev()
32
    {
33
        $this->option('production');
34
        return $this;
35
    }
36
37
    /**
38
     * @param null|string $pathToNpm
39
     *
40
     * @throws \Robo\Exception\TaskException
41
     */
42 View Code Duplication
    public function __construct($pathToNpm = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $this->command = $pathToNpm;
45
        if (!$this->command) {
46
            $this->command = $this->findExecutable('npm');
47
        }
48
        if (!$this->command) {
49
            throw new TaskException(__CLASS__, "Npm executable not found.");
50
        }
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getCommand()
57
    {
58
        return "{$this->command} {$this->action}{$this->arguments}";
59
    }
60
}
61