]> _ Git - cubist_util.git/commitdiff
wip #5422
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Aug 2022 16:04:13 +0000 (18:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Aug 2022 16:04:13 +0000 (18:04 +0200)
src/CommandLine.php
src/CommandLine/Imagemagick/Npx.php [deleted file]
src/CommandLine/Npx.php [new file with mode: 0644]

index 95cfe940f05997d31afc4595d2127864f6df275b..48320a062a2bd8b112ca3866ba936b2c9968d89e 100644 (file)
@@ -21,6 +21,7 @@ class CommandLine
     protected $ssh = null;
     protected $longArgSeparator = '=';
     protected $timeout = 0;
+    protected $json = false;
 
     function __construct($program, $output = null, $error = true)
     {
@@ -205,6 +206,10 @@ class CommandLine
             $commande = 'nohup ' . $commande;
         }
 
+        if ($this->json) {
+            $commande = 'sudo ' . $commande;
+        }
+
         $commandes[] = $commande;
 
         $this->commande = implode(';', $commandes);
@@ -296,4 +301,20 @@ class CommandLine
         $this->timeout = $timeout;
     }
 
+
+    /**
+     * @return bool
+     */
+    public function isJson(): bool
+    {
+        return $this->json;
+    }
+
+    /**
+     * @param bool $json
+     */
+    public function setJson(bool $json): void
+    {
+        $this->json = $json;
+    }
 }
diff --git a/src/CommandLine/Imagemagick/Npx.php b/src/CommandLine/Imagemagick/Npx.php
deleted file mode 100644 (file)
index 4c2d29e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-namespace Cubist\Util\CommandLine\Imagemagick;
-
-use Cubist\Util\CommandLine;
-
-class Npx extends CommandLine
-{
-    public function __construct($program = 'npx', $output = null, $error = true)
-    {
-        parent::__construct($program, $output, $error);
-    }
-
-    public function setModule($module)
-    {
-        $this->setManualArg($module);
-    }
-
-    public function execute($fonction = 'shell_exec')
-    {
-        parent::execute($fonction);
-    }
-}
\ No newline at end of file
diff --git a/src/CommandLine/Npx.php b/src/CommandLine/Npx.php
new file mode 100644 (file)
index 0000000..0f3824b
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Cubist\Util\CommandLine;
+
+use Cubist\Util\CommandLine;
+
+class Npx extends CommandLine
+{
+    public function __construct($program = 'npx', $output = null, $error = true)
+    {
+        parent::__construct($program, $output, $error);
+    }
+
+    public function setModule($module)
+    {
+        $this->setManualArg($module);
+    }
+
+    public function execute($fonction = 'shell_exec')
+    {
+        parent::execute($fonction);
+    }
+}
\ No newline at end of file