From 805abe8f511a1c6b8be11eeb08c32383e69b142f Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sun, 24 Aug 2025 14:45:56 +0000 Subject: [PATCH] bug fix in updater --- .../src/Command/UpdateSoftwareCommand.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hesabixCore/src/Command/UpdateSoftwareCommand.php b/hesabixCore/src/Command/UpdateSoftwareCommand.php index 787d191..81e0631 100644 --- a/hesabixCore/src/Command/UpdateSoftwareCommand.php +++ b/hesabixCore/src/Command/UpdateSoftwareCommand.php @@ -364,6 +364,11 @@ class UpdateSoftwareCommand extends Command 'HOME' => '/var/www', 'COMPOSER_HOME' => '/var/www/.composer', ]; + } elseif (in_array($command[0], ['npm', 'node'])) { + $env = [ + 'PATH' => '/usr/local/bin:/usr/bin:/bin:' . getenv('PATH'), + 'HOME' => '/var/www', + ]; } $process = new Process($command, $workingDir, $env); @@ -653,7 +658,19 @@ class UpdateSoftwareCommand extends Command $this->runProcess(['git', '--version'], $this->rootDir, $output, 1); $this->runProcess(['composer', '--version'], $this->rootDir, $output, 1, true); $this->runProcess(['php', '-v'], $this->rootDir, $output, 1); - $this->runProcess(['npm', '--version'], $this->rootDir, $output, 1); + + // Check npm with proper PATH + try { + $env = ['PATH' => '/usr/local/bin:/usr/bin:/bin:' . getenv('PATH')]; + $process = new Process(['npm', '--version'], $this->rootDir, $env); + $process->setTimeout(30); + $process->mustRun(); + $this->logger->info('Command executed successfully: npm --version'); + $this->writeOutput($output, $process->getOutput()); + } catch (ProcessFailedException $e) { + $this->logger->warning("Attempt 1 failed for npm --version: " . $e->getProcess()->getErrorOutput()); + $this->writeOutput($output, "Warning: npm not found or not accessible. Frontend build may fail."); + } $process = new Process(['whoami'], $this->rootDir); $process->run();