Documentation ¶
Overview ¶
utility package for nvm/utils
Useful only for nvm (not the nvm-shim)
Index ¶
- Constants
- Variables
- func CheckSha(node_body []byte, sha string) (err error)
- func DownloadNode(url string) (b []byte, err error)
- func FetchSha(url, filename string) (sha string, err error)
- func FlushTabs()
- func GetDownloadUrl(v common.Version, d exclusive_node_file) string
- func GetInstalledVersions() (versions []common.Version, err error)
- func GetLTS() (out common.Version, err error)
- func GetLatestFromVersion(version common.Version) (out common.Version, err error)
- func GetOsAndArch() (remote_os, remote_arch string)
- func PrintTabs(str string)
- func ProgressBar(b *[]byte, size int)
- func ReadNvmrc() (ver common.Version, err error)
- func Rename(source, target string) (err error)
- func UnArchiveBytes(b []byte, dir string) (err error)
- func UnArchiveReader(reader io.Reader, dir string) (err error)
- func ValidateUrl(url_str string) (string, error)
- type NodeDownload
Constants ¶
const INDEX = "index.tab"
const SHASUMS = "SHASUMS256.txt"
remote filename which indicates sha's for each downloadable file
Variables ¶
var BASE_URL = os.Getenv("NVM_NODEJS_ORG_MIRROR")
NVM_NODEJS_ORG_MIRROR - base url for downloading node; default: "https://nodejs.org/dist"
var CI = os.Getenv("CI")
CI usually sets CI=true? disable progress bars?
var ErrInvalidSha = errors.New("invalid sha")
error when verified sha did not match calculated file
var ErrNoNvmRc = errors.New("no .nvmrc found")
var ErrShaNotFound = errors.New("sha not found")
error when filename/sha not found
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
gets file sha and checks against a verified sha returns ErrInvalidSha
func DownloadNode ¶ added in v0.1.5
func GetDownloadUrl ¶ added in v0.1.4
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 GetLTS ¶ added in v0.1.5
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
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 ProgressBar ¶ added in v0.1.5
show a progress bar in stdout; needs bytes to be written using something like io.Reader.Read
func UnArchiveBytes ¶ added in v0.1.7
func UnArchiveReader ¶ added in v0.1.7
func ValidateUrl ¶ added in v0.1.5
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 )