Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed Aug 21, 2024
1 parent c9cd817 commit c5a3159
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Installer/VendorInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,19 @@ public function canInstallNvm(): bool
*/
public function installNvm(): void
{
$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";
$cmd = "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash";
$process = $this->execute->passThroughProcess(
Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null)
);
if (!$process->isSuccessful()) {
throw new \RuntimeException('nvm installation failed.');
}
putenv('NVM_DIR=' . $nvmDir);
preg_match('/^export NVM_DIR=(.+)$/m', trim($process->getOutput()), $matches);
if (isset($matches[1]) && is_dir($matches[1])) {
putenv('NVM_DIR=' . $matches[1]);
} else {
$this->getOutput()->debug('Can\'t retrieve NVM_DIR content from the command output.');
}
}

/**
Expand Down Expand Up @@ -155,7 +158,7 @@ public function installNode(): void
}

$nvmDir = getenv('NVM_DIR');
$cmd = ". $nvmDir/nvm.sh && nvm install && nvm use && echo \"NVM_BIN=\$NVM_BIN\"";
$cmd = ". {$nvmDir}/nvm.sh && nvm --version";

$process = $this->execute->passThroughProcess(
Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null)
Expand Down

0 comments on commit c5a3159

Please sign in to comment.