提交 a8a04173 编写于 作者: C Corey Butler

Added isVersionAvailable(). Fixes and closes #1.

上级 beb7e4a2
......@@ -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
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册