Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Task / Npm / Base.php
diff --git a/vendor/consolidation/robo/src/Task/Npm/Base.php b/vendor/consolidation/robo/src/Task/Npm/Base.php
new file mode 100644 (file)
index 0000000..35ff9c4
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+namespace Robo\Task\Npm;
+
+use Robo\Task\BaseTask;
+use Robo\Exception\TaskException;
+
+abstract class Base extends BaseTask
+{
+    use \Robo\Common\ExecOneCommand;
+
+    /**
+     * @var string
+     */
+    protected $command = '';
+
+    /**
+     * @var string[]
+     */
+    protected $opts = [];
+
+    /**
+     * @var string
+     */
+    protected $action = '';
+
+    /**
+     * adds `production` option to npm
+     *
+     * @return $this
+     */
+    public function noDev()
+    {
+        $this->option('production');
+        return $this;
+    }
+
+    /**
+     * @param null|string $pathToNpm
+     *
+     * @throws \Robo\Exception\TaskException
+     */
+    public function __construct($pathToNpm = null)
+    {
+        $this->command = $pathToNpm;
+        if (!$this->command) {
+            $this->command = $this->findExecutable('npm');
+        }
+        if (!$this->command) {
+            throw new TaskException(__CLASS__, "Npm executable not found.");
+        }
+    }
+
+    /**
+     * @return string
+     */
+    public function getCommand()
+    {
+        return "{$this->command} {$this->action}{$this->arguments}";
+    }
+}