Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e43ab4e4
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e43ab4e4
编写于
6月 18, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
差异文件
portable mode
上级
c473c552
76f39b2e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
138 addition
and
110 deletion
+138
-110
src/cli.js
src/cli.js
+33
-0
src/main.js
src/main.js
+77
-107
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+5
-0
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+20
-2
src/vs/platform/node/product.ts
src/vs/platform/node/product.ts
+1
-0
src/vs/workbench/parts/terminal/node/terminalProcess.ts
src/vs/workbench/parts/terminal/node/terminalProcess.ts
+2
-1
未找到文件。
src/cli.js
浏览文件 @
e43ab4e4
...
...
@@ -3,6 +3,39 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Error
.
stackTraceLimit
=
100
;
// increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
product
=
require
(
'
../product.json
'
);
const
appRoot
=
path
.
dirname
(
__dirname
);
function
getApplicationPath
()
{
if
(
process
.
env
[
'
VSCODE_DEV
'
])
{
return
appRoot
;
}
else
if
(
process
.
platform
===
'
darwin
'
)
{
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
appRoot
)));
}
else
{
return
path
.
dirname
(
path
.
dirname
(
appRoot
));
}
}
const
portableDataName
=
product
.
portable
||
`
${
product
.
applicationName
}
-portable-data`
;
const
portableDataPath
=
path
.
join
(
path
.
dirname
(
getApplicationPath
()),
portableDataName
);
const
isPortable
=
fs
.
existsSync
(
portableDataPath
);
const
portableTempPath
=
path
.
join
(
portableDataPath
,
'
tmp
'
);
const
isTempPortable
=
isPortable
&&
fs
.
existsSync
(
portableTempPath
);
if
(
isPortable
)
{
process
.
env
[
'
VSCODE_PORTABLE
'
]
=
portableDataPath
;
}
else
{
delete
process
.
env
[
'
VSCODE_PORTABLE
'
];
}
if
(
isTempPortable
)
{
process
.
env
[
process
.
platform
===
'
win32
'
?
'
TEMP
'
:
'
TMPDIR
'
]
=
portableTempPath
;
}
//#region Add support for using node_modules.asar
(
function
()
{
const
path
=
require
(
'
path
'
);
...
...
src/main.js
浏览文件 @
e43ab4e4
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
le
t
perf
=
require
(
'
./vs/base/common/performance
'
);
cons
t
perf
=
require
(
'
./vs/base/common/performance
'
);
perf
.
mark
(
'
main:started
'
);
// Perf measurements
...
...
@@ -12,6 +12,37 @@ global.perfStartTime = Date.now();
Error
.
stackTraceLimit
=
100
;
// increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
product
=
require
(
'
../product.json
'
);
const
appRoot
=
path
.
dirname
(
__dirname
);
function
getApplicationPath
()
{
if
(
process
.
env
[
'
VSCODE_DEV
'
])
{
return
appRoot
;
}
else
if
(
process
.
platform
===
'
darwin
'
)
{
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
appRoot
)));
}
else
{
return
path
.
dirname
(
path
.
dirname
(
appRoot
));
}
}
const
portableDataName
=
product
.
portable
||
`
${
product
.
applicationName
}
-portable-data`
;
const
portableDataPath
=
process
.
env
[
'
VSCODE_PORTABLE
'
]
||
path
.
join
(
path
.
dirname
(
getApplicationPath
()),
portableDataName
);
const
isPortable
=
fs
.
existsSync
(
portableDataPath
);
const
portableTempPath
=
path
.
join
(
portableDataPath
,
'
tmp
'
);
const
isTempPortable
=
isPortable
&&
fs
.
existsSync
(
portableTempPath
);
if
(
isPortable
)
{
process
.
env
[
'
VSCODE_PORTABLE
'
]
=
portableDataPath
;
}
else
{
delete
process
.
env
[
'
VSCODE_PORTABLE
'
];
}
if
(
isTempPortable
)
{
process
.
env
[
process
.
platform
===
'
win32
'
?
'
TEMP
'
:
'
TMPDIR
'
]
=
portableTempPath
;
}
//#region Add support for using node_modules.asar
(
function
()
{
const
path
=
require
(
'
path
'
);
...
...
@@ -36,7 +67,7 @@ Error.stackTraceLimit = 100; // increase number of stack frames (from 10, https:
})();
//#endregion
le
t
app
=
require
(
'
electron
'
).
app
;
cons
t
app
=
require
(
'
electron
'
).
app
;
// TODO@Ben Electron 2.0.x: prevent localStorage migration from SQLite to LevelDB due to issues
app
.
commandLine
.
appendSwitch
(
'
disable-mojo-local-storage
'
);
...
...
@@ -44,15 +75,19 @@ app.commandLine.appendSwitch('disable-mojo-local-storage');
// TODO@Ben Electron 2.0.x: force srgb color profile (for https://github.com/Microsoft/vscode/issues/51791)
app
.
commandLine
.
appendSwitch
(
'
force-color-profile
'
,
'
srgb
'
);
let
fs
=
require
(
'
fs
'
);
let
path
=
require
(
'
path
'
);
let
minimist
=
require
(
'
minimist
'
);
let
paths
=
require
(
'
./paths
'
);
const
minimist
=
require
(
'
minimist
'
);
const
paths
=
require
(
'
./paths
'
);
let
args
=
minimist
(
process
.
argv
,
{
string
:
[
'
user-data-dir
'
,
'
locale
'
]
const
args
=
minimist
(
process
.
argv
,
{
string
:
[
'
user-data-dir
'
,
'
locale
'
,
'
js-flags
'
,
'
max-memory
'
]
});
//#region NLS
function
stripComments
(
content
)
{
let
regexp
=
/
(
"
(?:[^\\\"]
*
(?:\\
.
)?)
*"
)
|
(
'
(?:[^\\\']
*
(?:\\
.
)?)
*'
)
|
(\/\*(?:\r?\n
|.
)
*
?\*\/)
|
(\/{2,}
.*
?(?:(?:\r?\n)
|$
))
/g
;
let
result
=
content
.
replace
(
regexp
,
function
(
match
,
m1
,
m2
,
m3
,
m4
)
{
...
...
@@ -77,113 +112,38 @@ function stripComments(content) {
return
result
;
}
let
_commit
;
function
getCommit
()
{
if
(
_commit
)
{
return
_commit
;
}
if
(
_commit
===
null
)
{
return
undefined
;
}
try
{
let
productJson
=
require
(
path
.
join
(
__dirname
,
'
../product.json
'
));
if
(
productJson
.
commit
)
{
_commit
=
productJson
.
commit
;
}
else
{
_commit
=
null
;
}
}
catch
(
exp
)
{
_commit
=
null
;
}
return
_commit
||
undefined
;
}
const
mkdir
=
dir
=>
new
Promise
((
c
,
e
)
=>
fs
.
mkdir
(
dir
,
err
=>
(
err
&&
err
.
code
!==
'
EEXIST
'
)
?
e
(
err
)
:
c
()));
const
exists
=
file
=>
new
Promise
(
c
=>
fs
.
exists
(
file
,
c
));
const
readFile
=
file
=>
new
Promise
((
c
,
e
)
=>
fs
.
readFile
(
file
,
'
utf8
'
,
(
err
,
data
)
=>
err
?
e
(
err
)
:
c
(
data
)));
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
const
touch
=
file
=>
new
Promise
((
c
,
e
)
=>
{
const
d
=
new
Date
();
fs
.
utimes
(
file
,
d
,
d
,
err
=>
err
?
e
(
err
)
:
c
());
});
function
mkdirp
(
dir
)
{
return
mkdir
(
dir
)
.
then
(
null
,
(
err
)
=>
{
return
mkdir
(
dir
).
then
(
null
,
err
=>
{
if
(
err
&&
err
.
code
===
'
ENOENT
'
)
{
let
parent
=
path
.
dirname
(
dir
);
if
(
parent
!==
dir
)
{
// if not arrived at root
return
mkdirp
(
parent
)
.
then
(()
=>
{
return
mkdir
(
dir
);
});
}
}
throw
err
;
});
}
function
mkdir
(
dir
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
mkdir
(
dir
,
(
err
)
=>
{
if
(
err
&&
err
.
code
!==
'
EEXIST
'
)
{
reject
(
err
);
}
else
{
resolve
(
dir
);
}
});
});
}
function
exists
(
file
)
{
return
new
Promise
((
resolve
)
=>
{
fs
.
exists
(
file
,
(
result
)
=>
{
resolve
(
result
);
});
});
}
const
parent
=
path
.
dirname
(
dir
);
function
readFile
(
file
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
readFile
(
file
,
'
utf8
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
reject
(
err
);
return
;
if
(
parent
!==
dir
)
{
// if not arrived at root
return
mkdirp
(
parent
).
then
(()
=>
mkdir
(
dir
));
}
resolve
(
data
);
});
});
}
function
writeFile
(
file
,
content
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
(
err
)
=>
{
if
(
err
)
{
reject
(
err
);
return
;
}
resolve
(
undefined
);
});
});
}
function
touch
(
file
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
d
=
new
Date
();
fs
.
utimes
(
file
,
d
,
d
,
(
err
)
=>
{
if
(
err
)
{
reject
(
err
);
return
;
}
resolve
(
undefined
);
});
throw
err
;
});
}
function
resolveJSFlags
()
{
let
jsFlags
=
[];
const
jsFlags
=
[];
if
(
args
[
'
js-flags
'
])
{
jsFlags
.
push
(
args
[
'
js-flags
'
]);
}
if
(
args
[
'
max-memory
'
]
&&
!
/max_old_space_size=
(\d
+
)
/g
.
exec
(
args
[
'
js-flags
'
]))
{
jsFlags
.
push
(
`--max_old_space_size=
${
args
[
'
max-memory
'
]}
`
);
}
if
(
jsFlags
.
length
>
0
)
{
return
jsFlags
.
join
(
'
'
);
}
else
{
return
null
;
}
return
jsFlags
.
length
>
0
?
jsFlags
.
join
(
'
'
)
:
null
;
}
// Language tags are case insensitve however an amd loader is case sensitive
...
...
@@ -288,7 +248,7 @@ function getNLSConfiguration(locale) {
}
perf
.
mark
(
'
nlsGeneration:start
'
);
let
defaultResult
=
function
(
locale
)
{
let
defaultResult
=
function
(
locale
)
{
let
isCoreLanguage
=
true
;
if
(
locale
)
{
isCoreLanguage
=
[
'
de
'
,
'
es
'
,
'
fr
'
,
'
it
'
,
'
ja
'
,
'
ko
'
,
'
ru
'
,
'
zh-cn
'
,
'
zh-tw
'
].
some
((
language
)
=>
{
...
...
@@ -305,7 +265,7 @@ function getNLSConfiguration(locale) {
}
};
try
{
let
commit
=
getCommit
()
;
let
commit
=
product
.
commit
;
if
(
!
commit
)
{
return
defaultResult
(
locale
);
}
...
...
@@ -342,7 +302,7 @@ function getNLSConfiguration(locale) {
return
exists
(
coreLocation
).
then
((
fileExists
)
=>
{
if
(
fileExists
)
{
// We don't wait for this. No big harm if we can't touch
touch
(
coreLocation
).
catch
(()
=>
{});
touch
(
coreLocation
).
catch
(()
=>
{
});
perf
.
mark
(
'
nlsGeneration:end
'
);
return
result
;
}
...
...
@@ -395,7 +355,9 @@ function getNLSConfiguration(locale) {
return
defaultResult
(
locale
);
}
}
//#endregion
//#region Cached Data Dir
function
getNodeCachedDataDir
()
{
// flag to disable cached data support
if
(
process
.
argv
.
indexOf
(
'
--no-cached-data
'
)
>
0
)
{
...
...
@@ -408,7 +370,7 @@ function getNodeCachedDataDir() {
}
// find commit id
let
commit
=
getCommit
()
;
let
commit
=
product
.
commit
;
if
(
!
commit
)
{
return
Promise
.
resolve
(
undefined
);
}
...
...
@@ -417,10 +379,18 @@ function getNodeCachedDataDir() {
return
mkdirp
(
dir
).
then
(
undefined
,
function
()
{
/*ignore*/
});
}
//#endregion
function
getUserDataPath
()
{
if
(
isPortable
)
{
return
path
.
join
(
portableDataPath
,
'
user-data
'
);
}
return
path
.
resolve
(
args
[
'
user-data-dir
'
]
||
paths
.
getDefaultUserDataPath
(
process
.
platform
));
}
// Set userData path before app 'ready' event and call to process.chdir
let
userData
=
path
.
resolve
(
args
[
'
user-data-dir
'
]
||
paths
.
getDefaultUserDataPath
(
process
.
platform
));
app
.
setPath
(
'
userData
'
,
userData
);
app
.
setPath
(
'
userData
'
,
getUserDataPath
());
// Update cwd based on environment and platform
try
{
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
e43ab4e4
...
...
@@ -323,6 +323,11 @@ function main() {
VSCODE_NLS_CONFIG
:
process
.
env
[
'
VSCODE_NLS_CONFIG
'
],
VSCODE_LOGS
:
process
.
env
[
'
VSCODE_LOGS
'
]
};
if
(
process
.
env
[
'
VSCODE_PORTABLE
'
])
{
instanceEnv
[
'
VSCODE_PORTABLE
'
]
=
process
.
env
[
'
VSCODE_PORTABLE
'
];
}
assign
(
process
.
env
,
instanceEnv
);
// Startup
...
...
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
e43ab4e4
...
...
@@ -90,7 +90,13 @@ export class EnvironmentService implements IEnvironmentService {
get
userHome
():
string
{
return
os
.
homedir
();
}
@
memoize
get
userDataPath
():
string
{
return
parseUserDataDir
(
this
.
_args
,
process
);
}
get
userDataPath
():
string
{
if
(
process
.
env
[
'
VSCODE_PORTABLE
'
])
{
return
path
.
join
(
process
.
env
[
'
VSCODE_PORTABLE
'
],
'
user-data
'
);
}
return
parseUserDataDir
(
this
.
_args
,
process
);
}
get
appNameLong
():
string
{
return
product
.
nameLong
;
}
...
...
@@ -127,7 +133,19 @@ export class EnvironmentService implements IEnvironmentService {
get
installSourcePath
():
string
{
return
path
.
join
(
this
.
userDataPath
,
'
installSource
'
);
}
@
memoize
get
extensionsPath
():
string
{
return
parsePathArg
(
this
.
_args
[
'
extensions-dir
'
],
process
)
||
process
.
env
[
'
VSCODE_EXTENSIONS
'
]
||
path
.
join
(
this
.
userHome
,
product
.
dataFolderName
,
'
extensions
'
);
}
get
extensionsPath
():
string
{
const
fromArgs
=
parsePathArg
(
this
.
_args
[
'
extensions-dir
'
],
process
);
if
(
fromArgs
)
{
return
fromArgs
;
}
else
if
(
process
.
env
[
'
VSCODE_EXTENSIONS
'
])
{
return
process
.
env
[
'
VSCODE_EXTENSIONS
'
];
}
else
if
(
process
.
env
[
'
VSCODE_PORTABLE
'
])
{
return
path
.
join
(
process
.
env
[
'
VSCODE_PORTABLE
'
],
'
extensions
'
);
}
else
{
return
path
.
join
(
this
.
userHome
,
product
.
dataFolderName
,
'
extensions
'
);
}
}
@
memoize
get
extensionDevelopmentPath
():
string
{
return
this
.
_args
.
extensionDevelopmentPath
?
path
.
normalize
(
this
.
_args
.
extensionDevelopmentPath
)
:
this
.
_args
.
extensionDevelopmentPath
;
}
...
...
src/vs/platform/node/product.ts
浏览文件 @
e43ab4e4
...
...
@@ -73,6 +73,7 @@ export interface IProductConfiguration {
'
darwin
'
:
string
;
};
logUploaderUrl
:
string
;
portable
?:
string
;
}
export
interface
ISurveyData
{
...
...
src/vs/workbench/parts/terminal/node/terminalProcess.ts
浏览文件 @
e43ab4e4
...
...
@@ -116,7 +116,8 @@ function cleanEnv() {
'
PTYCOLS
'
,
'
PTYROWS
'
,
'
PTYSHELLCMDLINE
'
,
'
VSCODE_LOGS
'
'
VSCODE_LOGS
'
,
'
VSCODE_PORTABLE
'
];
keys
.
forEach
(
function
(
key
)
{
if
(
process
.
env
[
key
])
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录