commands

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

commands holds all flagset commands for nvm:

  • install
  • use
  • list
  • uninstall
  • which

Example

nvm install 18.0.0
nvm use 18.0.0
node -v // v18.0.0

Index

Constants

View Source
const DEFAULT_BASE_URL = "https://nodejs.org/dist"

default download location

View Source
const SHASUMS = "SHASUMS256.txt"

remote filename which indicates sha's for each downloadable file

Variables

View Source
var BASE_URL = os.Getenv("NVM_NODEJS_ORG_MIRROR")

NVM_NODEJS_ORG_MIRROR - base url for downloading node; default: "https://nodejs.org/dist"

View Source
var InstallCmd = flag.NewFlagSet("install", flag.ContinueOnError)

flag set for commands.Install

flag set for commands.List

View Source
var UninstallCmd = flag.NewFlagSet("uninstall", flag.ContinueOnError)

flag set for commands.Uninstall

flag set for commands.Use

View Source
var WhichCmd = flag.NewFlagSet("which", flag.ContinueOnError)

flag set for commands.Which

Functions

func CheckSha

func CheckSha(fileName string, node_body, sha_body []byte) error

func Download

func Download(url string, ch chan []byte, err_ch chan error)

actually downloads a url and passes the []bytes to the channel; if there is an error, we pass it to `err_ch` used by commands.Install

func GetDownloadUrl

func GetDownloadUrl(v common.Version, d exclusive_node_file) string

determine where to download node install files

`v` a verified/parsed version string

`d` is a commands.NodeDownload

used by commands.Install

func GetOsAndArch

func GetOsAndArch() (remote_os, remote_arch string)

TODO: this can be cached, or run once used to determine download url in commands.GetDownloadUrl

func Install

func Install(args []string) (err error)

install a given node version TODO: install should output success message TODO: nvm install -h outputs help text twice TODO: install should always update/create symlinks in .nevermind/bin

func List

func List(cmd string, args []string) (err error)

list installed node versions

func Uninstall

func Uninstall(args []string) (err error)

uninstall a specific version of node

func Use

func Use(args []string) (err error)

use a version of node (updates config with desired version) TODO: use should output success message

func Which

func Which(cmd string, args []string) (err error)

get the path to the node executable for a given version

Types

type NodeDownload

type NodeDownload int

Enum for downloading either node or shasums

const (
	DOWNLOAD_NODE   NodeDownload = iota // downloads node
	DOWNLOAD_SHASUM                     // downloads SHASUMS
)

func (NodeDownload) X

func (d NodeDownload) X()

ignore me

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL