Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Task / Npm / Base.php
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     public function __construct($pathToNpm = null)
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 }