Skip to content

Commit

Permalink
PoC install nvm
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed Aug 20, 2024
1 parent 3842ad1 commit 0f8415f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Installer/VendorInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use MoodlePluginCI\Bridge\MoodlePlugin;
use MoodlePluginCI\Process\Execute;
use Symfony\Component\Process\Process;
use Symfony\Component\Filesystem\Filesystem;

/**
* Vendor installer.
Expand Down Expand Up @@ -119,9 +120,17 @@ public function installNode(): void
file_put_contents($this->moodle->directory . '/.nvmrc', $reqversion);
}

$nvmDir = getenv('NVM_DIR');
$cmd = ". $nvmDir/nvm.sh && nvm install && nvm use && echo \"NVM_BIN=\$NVM_BIN\"";
$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.');
}

$cmd = ". {$nvmDir}/nvm.sh && nvm install && nvm use && echo \"NVM_BIN=\$NVM_BIN\"";
$process = $this->execute->passThroughProcess(
Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null)
);
Expand Down

0 comments on commit 0f8415f

Please sign in to comment.