Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
风弥漫了夏天
nvm-windows
提交
c302a312
N
nvm-windows
项目概览
风弥漫了夏天
/
nvm-windows
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nvm-windows
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c302a312
编写于
10月 12, 2014
作者:
C
Corey Butler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed incomplete option.
上级
1d3233ca
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
31 addition
and
10 deletion
+31
-10
src/nvm.go
src/nvm.go
+31
-10
未找到文件。
src/nvm.go
浏览文件 @
c302a312
...
...
@@ -27,14 +27,18 @@ type Environment struct {
symlink
string
arch
string
proxy
string
originalpath
string
originalversion
string
}
var
env
=
&
Environment
{
settings
:
os
.
Getenv
(
"APPDATA"
)
+
"
\\
nvm
\\
settings.txt"
,
root
:
""
,
symlink
:
""
,
symlink
:
os
.
Getenv
(
"NVM_SYMLINK"
)
,
arch
:
os
.
Getenv
(
"PROCESSOR_ARCHITECTURE"
),
proxy
:
"none"
,
originalpath
:
""
,
originalversion
:
""
,
}
func
main
()
{
...
...
@@ -94,10 +98,24 @@ func main() {
env
.
proxy
=
detail
saveSettings
()
}
case
"update"
:
update
()
default
:
help
()
}
}
func
update
()
{
// cmd := exec.Command("cmd", "/d", "echo", "testing")
// var output bytes.Buffer
// var _stderr bytes.Buffer
// cmd.Stdout = &output
// cmd.Stderr = &_stderr
// perr := cmd.Run()
// if perr != nil {
// fmt.Println(fmt.Sprint(perr) + ": " + _stderr.String())
// return
// }
}
func
install
(
version
string
,
cpuarch
string
)
{
if
version
==
""
{
fmt
.
Println
(
"
\n
Invalid version.
\n
"
)
...
...
@@ -422,7 +440,8 @@ func help() {
fmt
.
Println
(
" nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy."
)
fmt
.
Println
(
" Set [url] to
\"
none
\"
to remove the proxy."
)
fmt
.
Println
(
" nvm uninstall <version> : The version must be a specific version."
)
fmt
.
Println
(
" nvm use <version> [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture."
)
// fmt.Println(" nvm update : Automatically update nvm to the latest version.")
fmt
.
Println
(
" nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture."
)
fmt
.
Println
(
" nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode."
)
fmt
.
Println
(
" nvm root [path] : Set the directory where nvm should store different versions of node.js."
)
fmt
.
Println
(
" If <path> is not set, the current root will be displayed."
)
...
...
@@ -458,7 +477,7 @@ func updateRootDir(path string) {
}
func
saveSettings
()
{
content
:=
"root: "
+
strings
.
Trim
(
env
.
root
,
"
\n\r
"
)
+
"
\r\n
path: "
+
strings
.
Trim
(
env
.
symlink
,
"
\n\r
"
)
+
"
\r\n
arch: "
+
strings
.
Trim
(
env
.
arch
,
"
\n\r
"
)
+
"
\r\n
proxy: "
+
strings
.
Trim
(
env
.
proxy
,
"
\n\r
"
)
content
:=
"root: "
+
strings
.
Trim
(
env
.
root
,
"
\n\r
"
)
+
"
\r\n
arch: "
+
strings
.
Trim
(
env
.
arch
,
"
\n\r
"
)
+
"
\r\n
proxy: "
+
strings
.
Trim
(
env
.
proxy
,
"
\n\r
"
)
+
"
\r\n
originalpath: "
+
strings
.
Trim
(
env
.
originalpath
,
"
\n\r
"
)
+
"
\r\n
originalversion: "
+
strings
.
Trim
(
env
.
originalversion
,
"
\n\r
"
)
ioutil
.
WriteFile
(
env
.
settings
,
[]
byte
(
content
),
0644
)
}
...
...
@@ -473,8 +492,10 @@ func Setup() {
for
_
,
line
:=
range
lines
{
if
strings
.
Contains
(
line
,
"root:"
)
{
env
.
root
=
strings
.
Trim
(
regexp
.
MustCompile
(
"root:"
)
.
ReplaceAllString
(
line
,
""
),
"
\r\n
"
)
}
else
if
strings
.
Contains
(
line
,
"path:"
)
{
env
.
symlink
=
strings
.
Trim
(
regexp
.
MustCompile
(
"path:"
)
.
ReplaceAllString
(
line
,
""
),
"
\r\n
"
)
}
else
if
strings
.
Contains
(
line
,
"originalpath:"
)
{
env
.
originalpath
=
strings
.
Trim
(
regexp
.
MustCompile
(
"originalpath:"
)
.
ReplaceAllString
(
line
,
""
),
"
\r\n
"
)
}
else
if
strings
.
Contains
(
line
,
"originalversion:"
)
{
env
.
originalversion
=
strings
.
Trim
(
regexp
.
MustCompile
(
"originalversion:"
)
.
ReplaceAllString
(
line
,
""
),
"
\r\n
"
)
}
else
if
strings
.
Contains
(
line
,
"arch:"
){
env
.
arch
=
strings
.
Trim
(
regexp
.
MustCompile
(
"arch:"
)
.
ReplaceAllString
(
line
,
""
),
"
\r\n
"
)
}
else
if
strings
.
Contains
(
line
,
"proxy:"
){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录