Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
风弥漫了夏天
nvm-windows
提交
256d6942
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 搜索 >>
提交
256d6942
编写于
8月 01, 2018
作者:
C
Corey Butler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated URLs to support npm >= 6.2.0. Applied several PR's. Bumped to v1.1.7
上级
476e11d1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
14 deletion
+30
-14
build.bat
build.bat
+1
-1
nvm.iss
nvm.iss
+1
-1
src/nvm.go
src/nvm.go
+26
-10
src/nvm/web/web.go
src/nvm/web/web.go
+2
-2
未找到文件。
build.bat
浏览文件 @
256d6942
...
...
@@ -4,7 +4,7 @@ SET ORIG=%CD%
REM SET GOPATH=%CD%\src
SET
GOBIN
=
%CD%
\bin
SET
GOARCH
=
386
SET
version
=
1
.1.
6
SET
version
=
1
.1.
7
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
...
...
nvm.iss
浏览文件 @
256d6942
#define MyAppName "NVM for Windows"
#define MyAppShortName "nvm"
#define MyAppLCShortName "nvm"
#define MyAppVersion "1.1.
6
"
#define MyAppVersion "1.1.
7
"
#define MyAppPublisher "Ecor Ventures LLC"
#define MyAppURL "http://github.com/coreybutler/nvm"
#define MyAppExeName "nvm.exe"
...
...
src/nvm.go
浏览文件 @
256d6942
...
...
@@ -2,6 +2,7 @@ package main
import
(
"fmt"
"log"
"os"
"os/exec"
"strings"
...
...
@@ -19,7 +20,7 @@ import (
)
const
(
NvmVersion
=
"1.1.
6
"
NvmVersion
=
"1.1.
7
"
)
type
Environment
struct
{
...
...
@@ -272,10 +273,19 @@ func install(version string, cpuarch string) {
tempDir
:=
filepath
.
Join
(
env
.
root
,
"temp"
)
// Extract npm to the temp directory
file
.
Unzip
(
filepath
.
Join
(
tempDir
,
"npm-v"
+
npmv
+
".zip"
),
filepath
.
Join
(
tempDir
,
"nvm-npm"
))
err
:=
file
.
Unzip
(
filepath
.
Join
(
tempDir
,
"npm-v"
+
npmv
+
".zip"
),
filepath
.
Join
(
tempDir
,
"nvm-npm"
))
// Copy the npm and npm.cmd files to the installation directory
tempNpmBin
:=
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
,
"bin"
)
tempNpmBin
:=
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"cli-"
+
npmv
,
"bin"
)
// Support npm < 6.2.0
if
file
.
Exists
(
tempNpmBin
)
==
false
{
tempNpmBin
=
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
,
"bin"
)
}
if
file
.
Exists
(
tempNpmBin
)
==
false
{
log
.
Fatal
(
"Failed to extract npm. Could not find "
+
tempNpmBin
)
}
// Standard npm support
os
.
Rename
(
filepath
.
Join
(
tempNpmBin
,
"npm"
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"npm"
))
...
...
@@ -286,14 +296,20 @@ func install(version string, cpuarch string) {
os
.
Rename
(
filepath
.
Join
(
tempNpmBin
,
"npx"
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"npx"
))
os
.
Rename
(
filepath
.
Join
(
tempNpmBin
,
"npx.cmd"
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"npx.cmd"
))
}
err
:=
os
.
Rename
(
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"node_modules"
,
"npm"
))
if
err
!=
nil
{
npmSourcePath
:=
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
)
if
file
.
Exists
(
npmSourcePath
)
==
false
{
npmSourcePath
=
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"cli-"
+
npmv
)
}
moveNpmErr
:=
os
.
Rename
(
npmSourcePath
,
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"node_modules"
,
"npm"
))
if
moveNpmErr
!=
nil
{
// sometimes Windows can take some time to enable access to large amounts of files after unzip, use exponential backoff to wait until it is ready
for
_
,
i
:=
range
[
5
]
int
{
1
,
2
,
4
,
8
,
16
}
{
time
.
Sleep
(
time
.
Duration
(
i
)
*
time
.
Second
)
e
rr
=
os
.
Rename
(
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"node_modules"
,
"npm"
))
if
e
rr
==
nil
{
break
}
moveNpmE
rr
=
os
.
Rename
(
filepath
.
Join
(
tempDir
,
"nvm-npm"
,
"npm-"
+
npmv
),
filepath
.
Join
(
env
.
root
,
"v"
+
version
,
"node_modules"
,
"npm"
))
if
moveNpmE
rr
==
nil
{
break
}
}
}
...
...
@@ -308,7 +324,7 @@ func install(version string, cpuarch string) {
}
}
else
{
fmt
.
Println
(
"Could not download npm for node v"
+
version
+
"."
)
fmt
.
Println
(
"Please visit https://github.com/npm/
npm
/releases/tag/v"
+
npmv
+
" to download npm."
)
fmt
.
Println
(
"Please visit https://github.com/npm/
cli
/releases/tag/v"
+
npmv
+
" to download npm."
)
fmt
.
Println
(
"It should be extracted to "
+
env
.
root
+
"
\\
v"
+
version
)
}
...
...
@@ -604,7 +620,7 @@ 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 node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url."
)
fmt
.
Println
(
" nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/
npm
/archive/. Leave [url] blank to default url."
)
fmt
.
Println
(
" nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/
cli
/archive/. Leave [url] blank to default url."
)
fmt
.
Println
(
" nvm uninstall <version> : The version must be a specific version."
)
// 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."
)
...
...
src/nvm/web/web.go
浏览文件 @
256d6942
...
...
@@ -18,7 +18,8 @@ import(
var
client
=
&
http
.
Client
{}
var
nodeBaseAddress
=
"https://nodejs.org/dist/"
var
npmBaseAddress
=
"https://github.com/npm/npm/archive/"
var
npmBaseAddress
=
"https://github.com/npm/cli/archive/"
// var oldNpmBaseAddress = "https://github.com/npm/npm/archive/"
func
SetProxy
(
p
string
,
verifyssl
bool
){
if
p
!=
""
&&
p
!=
"none"
{
...
...
@@ -143,7 +144,6 @@ func GetNodeJS(root string, v string, a string) bool {
}
func
GetNpm
(
root
string
,
v
string
)
bool
{
//url := "https://github.com/npm/npm/archive/v"+v+".zip"
url
:=
GetFullNpmUrl
(
"v"
+
v
+
".zip"
)
// temp directory to download the .zip file
tempDir
:=
root
+
"
\\
temp"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录