composer require --dev sweetchuck/robo-nvm
<?php
declare(strict_types = 1);
class RoboFile extends \Robo\Tasks
{
use \Sweetchuck\Robo\Nvm\NvmTaskLoader;
/**
* @command nvm:list-local
*/
public function nvmListLocal()
{
return $this
->collectionBuilder()
->addTask($this->taskNvmListLocal())
->addCode(function (\Robo\State\Data $data): int {
$output = $this->output();
$output->writeln(sprintf(
'Current node is: %s',
$data['nvm.listLocal.current'],
));
$output->writeln('Available NodeJS versions:');
foreach ($data['nvm.listLocal.versions'] as $value) {
$output->writeln(" $value");
}
return 0;
});
}
}
Run: vendor/bin/robo nvm:list-local
Current node is: v9.3.0 v9.3.0 v11.5.0 v15.0.1
<?php
declare(strict_types = 1);
class RoboFile extends \Robo\Tasks
{
use \Sweetchuck\Robo\Nvm\NvmTaskLoader;
/**
* @command nvm:which
*/
public function nvmWhich()
{
return $this
->collectionBuilder()
->addTask($this->taskNvmWhich())
->addCode(function (\Robo\State\Data $data): int {
$output = $this->output();
$output->writeln(sprintf(
'nvm.which.nodeExecutable = %s',
$data['nvm.which.nodeExecutable'],
));
$output->writeln(sprintf(
'nvm.which.binDir = %s',
$data['nvm.which.binDir'],
));
return 0;
});
}
}
Run: vendor/bin/robo nvm:which
nvm.which.nodeExecutable = /home/me/.nvm/versions/node/v9.3.0/bin/node nvm.which.binDir = /home/me/.nvm/versions/node/v9.3.0/bin