Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
风弥漫了夏天
nvm-windows
提交
37c72c70
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 搜索 >>
提交
37c72c70
编写于
2月 22, 2017
作者:
C
Corey Butler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for ignoring SSL validation. Fixed availability list.
上级
7275eb27
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
16 deletion
+36
-16
build.bat
build.bat
+1
-1
src/nvm.go
src/nvm.go
+29
-10
src/nvm/node/node.go
src/nvm/node/node.go
+1
-1
src/nvm/web/web.go
src/nvm/web/web.go
+5
-4
未找到文件。
build.bat
浏览文件 @
37c72c70
...
...
@@ -4,7 +4,7 @@ SET ORIG=%CD%
REM SET GOPATH=%CD%\src
SET
GOBIN
=
%CD%
\bin
SET
GOARCH
=
386
SET
version
=
1
.1.
1
SET
version
=
1
.1.
2
REM Get the version number from the setup file
REM for /f "tokens=*" %%i in ('findstr /n . %INNOSETUP% ^| findstr ^4:#define') do set L=%%i
...
...
src/nvm.go
浏览文件 @
37c72c70
...
...
@@ -16,7 +16,7 @@ import (
)
const
(
NvmVersion
=
"1.1.
1
"
NvmVersion
=
"1.1.
2
"
)
type
Environment
struct
{
...
...
@@ -29,6 +29,7 @@ type Environment struct {
proxy
string
originalpath
string
originalversion
string
verifyssl
bool
}
var
env
=
&
Environment
{
...
...
@@ -41,6 +42,7 @@ var env = &Environment{
proxy
:
"none"
,
originalpath
:
""
,
originalversion
:
""
,
verifyssl
:
true
,
}
func
main
()
{
...
...
@@ -55,7 +57,9 @@ func main() {
detail
=
args
[
2
]
}
if
len
(
args
)
>
3
{
procarch
=
args
[
3
]
if
(
args
[
3
]
==
"32"
||
args
[
3
]
==
"64"
)
{
procarch
=
args
[
3
]
}
}
if
len
(
args
)
<
2
{
help
()
...
...
@@ -122,11 +126,11 @@ func update() {
}
func
CheckVersionExceedsLatest
(
version
string
)
bool
{
//content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS256.txt")
url
:=
web
.
GetFullNodeUrl
(
"latest/SHASUMS256.txt"
);
content
:=
web
.
GetRemoteTextFile
(
url
)
re
:=
regexp
.
MustCompile
(
"node-v(.+)+msi"
)
reg
:=
regexp
.
MustCompile
(
"node-v|-x.+"
)
//content := web.GetRemoteTextFile("http://nodejs.org/dist/latest/SHASUMS256.txt")
url
:=
web
.
GetFullNodeUrl
(
"latest/SHASUMS256.txt"
);
content
:=
web
.
GetRemoteTextFile
(
url
)
re
:=
regexp
.
MustCompile
(
"node-v(.+)+msi"
)
reg
:=
regexp
.
MustCompile
(
"node-v|-x.+"
)
latest
:=
reg
.
ReplaceAllString
(
re
.
FindString
(
content
),
""
)
if
version
<=
latest
{
...
...
@@ -137,6 +141,13 @@ func CheckVersionExceedsLatest(version string) bool{
}
func
install
(
version
string
,
cpuarch
string
)
{
args
:=
os
.
Args
lastarg
:=
args
[
len
(
args
)
-
1
]
if
lastarg
==
"--insecure"
{
env
.
verifyssl
=
false
}
if
version
==
""
{
fmt
.
Println
(
"
\n
Invalid version."
)
fmt
.
Println
(
" "
)
...
...
@@ -194,6 +205,11 @@ func install(version string, cpuarch string) {
os
.
Mkdir
(
env
.
root
+
"
\\
v"
+
version
,
os
.
ModeDir
)
os
.
Mkdir
(
env
.
root
+
"
\\
v"
+
version
+
"
\\
node_modules"
,
os
.
ModeDir
)
// Warn the user if they're attempting to install without verifying the remote SSL cert
if
!
env
.
verifyssl
{
fmt
.
Println
(
"
\n
WARNING: The remote SSL certificate will not be validated during the download process.
\n
"
)
}
// Download node
if
(
cpuarch
==
"32"
||
cpuarch
==
"all"
)
&&
!
node
.
IsVersionInstalled
(
env
.
root
,
version
,
"32"
)
{
success
:=
web
.
GetNodeJS
(
env
.
root
,
version
,
"32"
);
...
...
@@ -244,9 +260,11 @@ func install(version string, cpuarch string) {
fmt
.
Println
(
"It should be extracted to "
+
env
.
root
+
"
\\
v"
+
version
)
}
// Reset the SSL verification
env
.
verifyssl
=
true
// If this is ever shipped for Mac, it should use homebrew.
// If this ever ships on Linux, it should be on bintray so it can use yum, apt-get, etc.
return
}
else
{
fmt
.
Println
(
"Version "
+
version
+
" is already installed."
)
...
...
@@ -517,7 +535,8 @@ func help() {
fmt
.
Println
(
" nvm install <version> [arch] : The version can be a node.js version or
\"
latest
\"
for the latest stable version."
)
fmt
.
Println
(
" Optionally specify whether to install the 32 or 64 bit version (defaults to system arch)."
)
fmt
.
Println
(
" Set [arch] to
\"
all
\"
to install 32 AND 64 bit versions."
)
fmt
.
Println
(
" nvm list [available] : List the node.js installations. Type
\"
available
\"
at the end to see what can be installed. Aliased as ls."
)
fmt
.
Println
(
" Add --insecure to the end of this command to bypass SSL validation of the remote download server."
)
fmt
.
Println
(
" nvm list [available] : List the node.js installations. Type
\"
available
\"
at the end to see what can be installed. Aliased as ls."
)
fmt
.
Println
(
" nvm on : Enable node.js version management."
)
fmt
.
Println
(
" nvm off : Disable node.js version management."
)
fmt
.
Println
(
" nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy."
)
...
...
@@ -588,7 +607,7 @@ func Setup() {
if
strings
.
ToLower
(
env
.
proxy
[
0
:
4
])
!=
"http"
{
env
.
proxy
=
"http://"
+
env
.
proxy
}
web
.
SetProxy
(
env
.
proxy
)
web
.
SetProxy
(
env
.
proxy
,
env
.
verifyssl
)
}
}
}
...
...
src/nvm/node/node.go
浏览文件 @
37c72c70
...
...
@@ -131,7 +131,7 @@ func isCurrent(element map[string]interface{}) bool {
return
false
}
return
version
.
Major
%
2
==
0
return
version
.
Major
%
2
==
1
}
// Identifies a stable old version.
...
...
src/nvm/web/web.go
浏览文件 @
37c72c70
...
...
@@ -7,6 +7,7 @@ import(
"os"
"io"
"io/ioutil"
"crypto/tls"
"strings"
"strconv"
"../arch"
...
...
@@ -17,12 +18,12 @@ var client = &http.Client{}
var
nodeBaseAddress
=
"https://nodejs.org/dist/"
var
npmBaseAddress
=
"https://github.com/npm/npm/archive/"
func
SetProxy
(
p
string
){
func
SetProxy
(
p
string
,
verifyssl
bool
){
if
p
!=
""
&&
p
!=
"none"
{
proxyUrl
,
_
:=
url
.
Parse
(
p
)
client
=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
Proxy
:
http
.
ProxyURL
(
proxyUrl
)}}
client
=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
Proxy
:
http
.
ProxyURL
(
proxyUrl
)
,
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
verifyssl
}
}}
}
else
{
client
=
&
http
.
Client
{}
client
=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
verifyssl
}}
}
}
}
...
...
@@ -101,7 +102,7 @@ func GetNodeJS(root string, v string, a string) bool {
vpre
=
"x64/"
}
}
url
:=
getNodeUrl
(
v
,
vpre
);
if
url
==
""
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录