Skip to content

Commit

Permalink
Fix nvm node_mirror, npm_mirror doesn't work issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Excited-ccccly committed Mar 5, 2017
1 parent 8889f64 commit 0467ddd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,22 @@ func main() {
saveSettings()
}
case "update": update()
case "node_mirror": setNodeMirror(detail)
case "npm_mirror": setNpmMirror(detail)
default: help()
}
}

func setNodeMirror(detail string) {
env.node_mirror = detail
saveSettings()
}

func setNpmMirror(detail string) {
env.npm_mirror = detail
saveSettings()
}

func update() {
// cmd := exec.Command("cmd", "/d", "echo", "testing")
// var output bytes.Buffer
Expand Down Expand Up @@ -574,8 +586,8 @@ func updateRootDir(path string) {
}

func saveSettings() {
content := "root: "+strings.Trim(env.root," \n\r")+"\r\narch: "+strings.Trim(env.arch," \n\r")+"\r\nproxy: "+strings.Trim(env.proxy," \n\r")+"\r\noriginalpath: "+strings.Trim(env.originalpath," \n\r")+"\r\noriginalversion: "+strings.Trim(env.originalversion," \n\r")
content = content + "node_mirror: "+strings.Trim(env.node_mirror," \n\r")+ "npm_mirror: "+strings.Trim(env.npm_mirror," \n\r")
content := "root: " + strings.Trim(env.root, " \n\r") + "\r\narch: " + strings.Trim(env.arch, " \n\r") + "\r\nproxy: " + strings.Trim(env.proxy, " \n\r") + "\r\noriginalpath: " + strings.Trim(env.originalpath, " \n\r") + "\r\noriginalversion: " + strings.Trim(env.originalversion, " \n\r")
content = content + "\r\nnode_mirror: " + strings.Trim(env.node_mirror, " \n\r") + "\r\nnpm_mirror: " + strings.Trim(env.npm_mirror, " \n\r")
ioutil.WriteFile(env.settings, []byte(content), 0644)
}

Expand Down

0 comments on commit 0467ddd

Please sign in to comment.