sweetchuck/robo-nvm

Robo task wrapper for NVM commands.

Installs: 70 107

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

Type:robo-tasks

v1.0.0-alpha1 2020-12-26 21:40 UTC

This package is auto-updated.

Last update: 2022-01-02 11:11:18 UTC


README

CircleCI codecov

Install

composer require --dev sweetchuck/robo-nvm

Task - taskNvmListLocal

<?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

Task - taskNvmWhich

<?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