]> _ Git - cubist_util.git/commitdiff
wip #6986 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jul 2024 09:51:13 +0000 (11:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jul 2024 09:51:13 +0000 (11:51 +0200)
src/CommandLine.php

index ebbf377342cc8faa990976759951f2ee4dbe173b..6bba3eb274ada8c0553573e25df0a02556976352 100644 (file)
@@ -3,6 +3,7 @@
 namespace Cubist\Util;
 
 use Cubist\Net\SSH2;
+use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Support\Facades\Log;
 
 class CommandLine
@@ -125,23 +126,24 @@ class CommandLine
 
         $startTime = microtime(true);
         $this->_preExecute();
+        $measure = app() instanceof Application && function_exists('start_measure') && function_exists('stop_measure');
         if ($fonction instanceof SSH2) {
             $this->makeCommande();
-            if (function_exists('start_measure')) {
+            if ($measure) {
                 start_measure('Exec CLI : ' . $this->commande);
             }
             $o = $fonction->exec($this->commande);
-            if (function_exists('stop_measure')) {
+            if ($measure) {
                 stop_measure('Exec CLI : ' . $this->commande);
             }
             file_put_contents($this->output, $o['output'] . "\n\n---\n\n" . $o['error']);
         } else if (null === $this->ssh) {
             $this->makeCommande($this->output, $this->error);
-            if (function_exists('start_measure')) {
+            if ($measure) {
                 start_measure('Exec CLI : ' . $this->commande);
             }
             $fonction($this->commande);
-            if (function_exists('stop_measure')) {
+            if ($measure) {
                 stop_measure('Exec CLI : ' . $this->commande);
             }
         } else {
@@ -159,11 +161,12 @@ class CommandLine
             }
 
             $this->commande = $c;
-            if (function_exists('start_measure')) {
+
+            if ($measure) {
                 start_measure('Exec CLI : ' . $this->commande);
             }
             $fonction($c);
-            if (function_exists('stop_measure')) {
+            if ($measure) {
                 stop_measure('Exec CLI : ' . $this->commande);
             }
         }