mirror of
https://github.com/coreybutler/nvm-windows.git
synced 2026-01-14 07:03:17 +08:00
Added isVersionAvailable(). Fixes and closes #1.
This commit is contained in:
21
src/nvm.go
21
src/nvm.go
@@ -73,6 +73,13 @@ func install(version string) {
|
||||
// Check to see if the version is already installed
|
||||
if !isVersionInstalled(version) {
|
||||
|
||||
if !isVersionAvailable(version){
|
||||
fmt.Println("Version "+version+" is not available. If you are attempting to download a \"just released\" version,")
|
||||
fmt.Println("it may not be recognized by the nvm service yet (updated hourly). If you feel this is in error and")
|
||||
fmt.Println("you know the version exists, please visit http://github.com/coreybutler/nodedistro and submit a PR.")
|
||||
return
|
||||
}
|
||||
|
||||
// Make the output directories
|
||||
os.Mkdir(root+"\\v"+version,os.ModeDir)
|
||||
os.Mkdir(root+"\\v"+version+"\\node_modules",os.ModeDir)
|
||||
@@ -468,3 +475,17 @@ func setRootDir() {
|
||||
p=p
|
||||
}
|
||||
}
|
||||
|
||||
func isVersionAvailable(v string) bool {
|
||||
// Check the service to make sure the version is available
|
||||
text := getRemoteTextFile("https://raw.githubusercontent.com/coreybutler/nodedistro/master/nodeversions.json")
|
||||
|
||||
// Parse
|
||||
var data interface{}
|
||||
json.Unmarshal([]byte(text), &data);
|
||||
body := data.(map[string]interface{})
|
||||
all := body["all"]
|
||||
npm := all.(map[string]interface{})
|
||||
|
||||
return npm[v] != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user