utils

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

utility package for nvm/utils

Useful only for nvm (not the nvm-shim)

Index

Constants

View Source
const INDEX = "index.tab"
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 CI = os.Getenv("CI")

CI usually sets CI=true? disable progress bars?

View Source
var ErrInvalidSha = errors.New("invalid sha")

error when verified sha did not match calculated file

View Source
var ErrNoNvmRc = errors.New("no .nvmrc found")
View Source
var ErrShaNotFound = errors.New("sha not found")

error when filename/sha not found

View Source
var Writer = tabwriter.NewWriter(os.Stderr, 1, 1, 4, ' ', 0)

customized writer to print help logs nicely

Functions

func CheckSha added in v0.1.4

func CheckSha(node_body []byte, sha string) (err error)

gets file sha and checks against a verified sha returns ErrInvalidSha

func DownloadNode added in v0.1.5

func DownloadNode(url string) (b []byte, err error)

func FetchSha added in v0.1.5

func FetchSha(url, filename string) (sha string, err error)

downloads shasums and gets verified sha for a filename

func FlushTabs

func FlushTabs()

flush tabbed output to stdout

func GetDownloadUrl added in v0.1.4

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 GetInstalledVersions added in v0.1.6

func GetInstalledVersions() (versions []common.Version, err error)

func GetLTS added in v0.1.5

func GetLTS() (out common.Version, err error)

version is non-specific and we need to query the releases to find the latest version which fits the range

func GetLatestFromVersion added in v0.1.5

func GetLatestFromVersion(version common.Version) (out common.Version, err error)

version is non-specific and we need to query the releases to find the latest version which fits the range

func GetOsAndArch added in v0.1.4

func GetOsAndArch() (remote_os, remote_arch string)

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

func PrintTabs

func PrintTabs(str string)

aligns tabs with tabwriter

func ProgressBar added in v0.1.5

func ProgressBar(b *[]byte, size int)

show a progress bar in stdout; needs bytes to be written using something like io.Reader.Read

func ReadNvmrc added in v0.1.6

func ReadNvmrc() (ver common.Version, err error)

get version in .nvmrc

func Rename

func Rename(source, target string) (err error)

rename or move file; moving may be required if using a docker container with volumes

func UnArchiveBytes added in v0.1.7

func UnArchiveBytes(b []byte, dir string) (err error)

func UnArchiveReader added in v0.1.7

func UnArchiveReader(reader io.Reader, dir string) (err error)

func ValidateUrl added in v0.1.5

func ValidateUrl(url_str string) (string, error)

check that a url string is valid

Types

type NodeDownload added in v0.1.4

type NodeDownload int

Enum for downloading either node or shasums

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

Jump to

Keyboard shortcuts

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