Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
风弥漫了夏天
nvm-windows
提交
09da8d90
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,体验更适合开发者的 AI 搜索 >>
提交
09da8d90
编写于
9月 30, 2015
作者:
C
Corey Butler
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #94 from sullivanpt/develop
Fixed for node v4
上级
32b87547
0bc5644a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
40 deletion
+70
-40
nvm.iss
nvm.iss
+1
-1
src/nvm.go
src/nvm.go
+11
-11
src/nvm/node/node.go
src/nvm/node/node.go
+15
-11
src/nvm/web/web.go
src/nvm/web/web.go
+43
-17
未找到文件。
nvm.iss
浏览文件 @
09da8d90
#define MyAppName "NVM for Windows"
#define MyAppShortName "nvm"
#define MyAppLCShortName "nvm"
#define MyAppVersion "1.
0.6
"
#define MyAppVersion "1.
1.0
"
#define MyAppPublisher "Ecor Ventures, LLC"
#define MyAppURL "http://github.com/coreybutler/nvm"
#define MyAppExeName "nvm.exe"
...
...
src/nvm.go
浏览文件 @
09da8d90
...
...
@@ -18,7 +18,7 @@ import (
)
const
(
NvmVersion
=
"1.
0.6
"
NvmVersion
=
"1.
1.0
"
)
type
Environment
struct
{
...
...
@@ -120,11 +120,11 @@ func update() {
}
func
CheckVersionExceedsLatest
(
version
string
)
bool
{
content
:=
web
.
GetRemoteTextFile
(
"http://nodejs.org/dist/latest/SHASUMS.txt"
)
content
:=
web
.
GetRemoteTextFile
(
"http://nodejs.org/dist/latest/SHASUMS
256
.txt"
)
re
:=
regexp
.
MustCompile
(
"node-v(.+)+msi"
)
reg
:=
regexp
.
MustCompile
(
"node-v|-x.+"
)
latest
:=
reg
.
ReplaceAllString
(
re
.
FindString
(
content
),
""
)
if
version
<=
latest
{
return
false
}
else
{
...
...
@@ -155,6 +155,14 @@ func install(version string, cpuarch string) {
cpuarch
=
arch
.
Validate
(
cpuarch
)
}
// If user specifies "latest" version, find out what version is
if
version
==
"latest"
{
content
:=
web
.
GetRemoteTextFile
(
"http://nodejs.org/dist/latest/SHASUMS256.txt"
)
re
:=
regexp
.
MustCompile
(
"node-v(.+)+msi"
)
reg
:=
regexp
.
MustCompile
(
"node-v|-x.+"
)
version
=
reg
.
ReplaceAllString
(
re
.
FindString
(
content
),
""
)
}
if
CheckVersionExceedsLatest
(
version
)
{
fmt
.
Println
(
"Node.js v"
+
version
+
" is not yet released or available."
)
return
...
...
@@ -165,14 +173,6 @@ func install(version string, cpuarch string) {
return
}
// If user specifies "latest" version, find out what version is
if
version
==
"latest"
{
content
:=
web
.
GetRemoteTextFile
(
"http://nodejs.org/dist/latest/SHASUMS.txt"
)
re
:=
regexp
.
MustCompile
(
"node-v(.+)+msi"
)
reg
:=
regexp
.
MustCompile
(
"node-v|-x.+"
)
version
=
reg
.
ReplaceAllString
(
re
.
FindString
(
content
),
""
)
}
// Check to see if the version is already installed
if
!
node
.
IsVersionInstalled
(
env
.
root
,
version
,
cpuarch
)
{
...
...
src/nvm/node/node.go
浏览文件 @
09da8d90
...
...
@@ -25,17 +25,21 @@ func GetCurrentVersion() (string, string) {
cmd
:=
exec
.
Command
(
"node"
,
"-p"
,
"console.log(process.execPath)"
)
str
,
_
:=
cmd
.
Output
()
file
:=
strings
.
Trim
(
regexp
.
MustCompile
(
"undefined"
)
.
ReplaceAllString
(
string
(
str
),
""
),
"
\n\r
"
)
bit
:=
arch
.
Bit
(
file
)
if
(
bit
==
"?"
){
cmd
:=
exec
.
Command
(
"node"
,
"-e"
,
"console.log(process.arch)"
)
str
,
err
:=
cmd
.
Output
()
if
(
string
(
str
)
==
"x64"
)
{
bit
:=
"64"
}
else
{
bit
:=
"32"
}
}
return
v
,
bit
bit
:=
arch
.
Bit
(
file
)
if
(
bit
==
"?"
){
cmd
:=
exec
.
Command
(
"node"
,
"-e"
,
"console.log(process.arch)"
)
str
,
err
:=
cmd
.
Output
()
if
(
err
==
nil
)
{
if
(
string
(
str
)
==
"x64"
)
{
bit
=
"64"
}
else
{
bit
=
"32"
}
}
else
{
return
v
,
"Unknown"
}
}
return
v
,
bit
}
return
"Unknown"
,
""
}
...
...
src/nvm/web/web.go
浏览文件 @
09da8d90
...
...
@@ -59,26 +59,42 @@ func GetNodeJS(root string, v string, a string) bool {
a
=
arch
.
Validate
(
a
)
url
:=
""
vpre
:=
""
vers
:=
strings
.
Fields
(
strings
.
Replace
(
v
,
"."
,
" "
,
-
1
))
main
,
_
:=
strconv
.
ParseInt
(
vers
[
0
],
0
,
0
)
if
a
==
"32"
{
url
=
"http://nodejs.org/dist/v"
+
v
+
"/node.exe"
}
else
{
if
!
IsNode64bitAvailable
(
v
)
{
fmt
.
Println
(
"Node.js v"
+
v
+
" is only available in 32-bit."
)
return
false
if
main
>
0
{
vpre
=
"win-x86/"
}
else
{
vpre
=
""
}
}
else
if
a
==
"64"
{
if
main
>
0
{
vpre
=
"win-x64/"
}
else
{
vpre
=
"x64/"
}
url
=
"http://nodejs.org/dist/v"
+
v
+
"/x64/node.exe"
}
fileName
:=
root
+
"
\\
v"
+
v
+
"
\\
node"
+
a
+
".exe"
url
:=
getNodeUrl
(
v
,
vpre
);
fmt
.
Printf
(
"Downloading node.js version "
+
v
+
" ("
+
a
+
"-bit)... "
)
if
Download
(
url
,
fileName
)
{
fmt
.
Printf
(
"Complete
\n
"
)
return
true
if
url
==
""
{
//No url should mean this version/arch isn't available
fmt
.
Println
(
"Node.js v"
+
v
+
" "
+
a
+
"bit isn't available right now."
)
}
else
{
return
false
fileName
:=
root
+
"
\\
v"
+
v
+
"
\\
node"
+
a
+
".exe"
fmt
.
Printf
(
"Downloading node.js version "
+
v
+
" ("
+
a
+
"-bit)... "
)
if
Download
(
url
,
fileName
)
{
fmt
.
Printf
(
"Complete
\n
"
)
return
true
}
else
{
return
false
}
}
return
false
}
...
...
@@ -139,10 +155,20 @@ func IsNode64bitAvailable(v string) bool {
return
false
}
// TODO: fixme. Assume a 64 bit version exists
return
true
}
func
getNodeUrl
(
v
string
,
vpre
string
)
string
{
url
:=
"http://nodejs.org/dist/v"
+
v
+
"/"
+
vpre
+
"/node.exe"
// Check online to see if a 64 bit version exists
res
,
err
:=
client
.
Head
(
"http://nodejs.org/dist/v"
+
v
+
"/x64/node.exe"
)
res
,
err
:=
client
.
Head
(
url
)
if
err
!=
nil
{
return
false
return
""
}
if
res
.
StatusCode
==
200
{
return
url
}
else
{
return
""
}
return
res
.
StatusCode
==
200
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录