diff --git a/src/Installer/VendorInstaller.php b/src/Installer/VendorInstaller.php index cd12903f..c4e56c31 100644 --- a/src/Installer/VendorInstaller.php +++ b/src/Installer/VendorInstaller.php @@ -15,6 +15,7 @@ use MoodlePluginCI\Bridge\Moodle; use MoodlePluginCI\Bridge\MoodlePlugin; use MoodlePluginCI\Process\Execute; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; /** @@ -112,15 +113,16 @@ public function canInstallNvm(): bool */ public function installNvm(): void { - $cmd = 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'; + $nvmDir = "{$this->moodle->directory}/.nvm"; + (new Filesystem())->mkdir($nvmDir); + $cmd = "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | NVM_DIR={$nvmDir} bash"; $process = $this->execute->passThroughProcess( Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null) ); if (!$process->isSuccessful()) { throw new \RuntimeException('nvm installation failed.'); } - $home = getenv('HOME'); - putenv("NVM_DIR={$home}/.nvm"); + putenv("NVM_DIR={$nvmDir}"); } /**