Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
cpas6-install
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李金钢
cpas6-install
Commits
2d79693e
Commit
2d79693e
authored
Mar 19, 2026
by
Auto Backup
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: change all Chinese output to English in check-environment.js
parent
62567761
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
check-environment.js
check-environment.js
+21
-21
No files found.
check-environment.js
View file @
2d79693e
...
@@ -15,31 +15,31 @@ const isLinux = os.platform() === 'linux';
...
@@ -15,31 +15,31 @@ const isLinux = os.platform() === 'linux';
console
.
log
(
`Platform:
${
os
.
platform
()}
(
${
isWindows
?
'Windows'
:
isMacOS
?
'macOS'
:
isLinux
?
'Linux'
:
'Other'
}
)`
);
console
.
log
(
`Platform:
${
os
.
platform
()}
(
${
isWindows
?
'Windows'
:
isMacOS
?
'macOS'
:
isLinux
?
'Linux'
:
'Other'
}
)`
);
/**
/**
*
打印环境变量信息
*
Print environment variables information
*/
*/
function
printEnvironmentInfo
()
{
function
printEnvironmentInfo
()
{
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
'
当前环境变量信息
'
);
console
.
log
(
'
Environment Variables Information
'
);
console
.
log
(
'==========================================
\
n'
);
console
.
log
(
'==========================================
\
n'
);
//
关键环境变量
//
Key environment variables
const
keyVars
=
[
'PATH'
,
'NODE_PATH'
,
'HOME'
,
'USER'
,
'USERNAME'
,
'TEMP'
,
'TMP'
,
'PROCESSOR_ARCHITECTURE'
,
'OS'
,
'PATHEXT'
,
'COMSPEC'
,
'SystemRoot'
];
const
keyVars
=
[
'PATH'
,
'NODE_PATH'
,
'HOME'
,
'USER'
,
'USERNAME'
,
'TEMP'
,
'TMP'
,
'PROCESSOR_ARCHITECTURE'
,
'OS'
,
'PATHEXT'
,
'COMSPEC'
,
'SystemRoot'
];
console
.
log
(
'🔍
关键环境变量
:
\
n'
);
console
.
log
(
'🔍
Key Environment Variables
:
\
n'
);
for
(
const
key
of
keyVars
)
{
for
(
const
key
of
keyVars
)
{
if
(
process
.
env
[
key
])
{
if
(
process
.
env
[
key
])
{
console
.
log
(
`
${
key
}
:
${
process
.
env
[
key
]}
`
);
console
.
log
(
`
${
key
}
:
${
process
.
env
[
key
]}
`
);
}
}
}
}
console
.
log
(
'
\
n🔍 PATH
详细内容
:
\
n'
);
console
.
log
(
'
\
n🔍 PATH
Details
:
\
n'
);
const
pathSeparator
=
isWindows
?
';'
:
':'
;
const
pathSeparator
=
isWindows
?
';'
:
':'
;
const
pathDirs
=
(
process
.
env
.
PATH
||
''
).
split
(
pathSeparator
);
const
pathDirs
=
(
process
.
env
.
PATH
||
''
).
split
(
pathSeparator
);
pathDirs
.
forEach
((
dir
,
index
)
=>
{
pathDirs
.
forEach
((
dir
,
index
)
=>
{
console
.
log
(
` [
${
index
+
1
}
]
${
dir
}
`
);
console
.
log
(
` [
${
index
+
1
}
]
${
dir
}
`
);
});
});
console
.
log
(
'
\
n🔍 Node.js
相关环境变量
:
\
n'
);
console
.
log
(
'
\
n🔍 Node.js
Related Environment Variables
:
\
n'
);
const
nodeVars
=
[
'NODE'
,
'NODE_OPTIONS'
,
'npm_config_prefix'
,
'npm_config_cache'
,
'APPDATA'
,
'LOCALAPPDATA'
];
const
nodeVars
=
[
'NODE'
,
'NODE_OPTIONS'
,
'npm_config_prefix'
,
'npm_config_cache'
,
'APPDATA'
,
'LOCALAPPDATA'
];
for
(
const
key
of
nodeVars
)
{
for
(
const
key
of
nodeVars
)
{
if
(
process
.
env
[
key
])
{
if
(
process
.
env
[
key
])
{
...
@@ -47,7 +47,7 @@ function printEnvironmentInfo() {
...
@@ -47,7 +47,7 @@ function printEnvironmentInfo() {
}
}
}
}
console
.
log
(
'
\
n🔍 SSH
和 Git 相关环境变量
:
\
n'
);
console
.
log
(
'
\
n🔍 SSH
and Git Related Environment Variables
:
\
n'
);
const
gitVars
=
[
'GIT_SSH'
,
'GIT_SSH_COMMAND'
,
'GIT_TERMINAL_PROMPT'
,
'SSH_AUTH_SOCK'
,
'SSH_AGENT_PID'
,
'GIT_EXEC_PATH'
];
const
gitVars
=
[
'GIT_SSH'
,
'GIT_SSH_COMMAND'
,
'GIT_TERMINAL_PROMPT'
,
'SSH_AUTH_SOCK'
,
'SSH_AGENT_PID'
,
'GIT_EXEC_PATH'
];
for
(
const
key
of
gitVars
)
{
for
(
const
key
of
gitVars
)
{
if
(
process
.
env
[
key
])
{
if
(
process
.
env
[
key
])
{
...
@@ -55,37 +55,37 @@ function printEnvironmentInfo() {
...
@@ -55,37 +55,37 @@ function printEnvironmentInfo() {
}
}
}
}
console
.
log
(
'
\
n🔍
所有环境变量列表
:
\
n'
);
console
.
log
(
'
\
n🔍
All Environment Variables
:
\
n'
);
const
allEnvVars
=
Object
.
keys
(
process
.
env
).
sort
();
const
allEnvVars
=
Object
.
keys
(
process
.
env
).
sort
();
allEnvVars
.
forEach
((
key
)
=>
{
allEnvVars
.
forEach
((
key
)
=>
{
console
.
log
(
`
${
key
}
=
${
process
.
env
[
key
]}
`
);
console
.
log
(
`
${
key
}
=
${
process
.
env
[
key
]}
`
);
});
});
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
'
环境变量打印完成
'
);
console
.
log
(
'
Environment Variables Dump Complete
'
);
console
.
log
(
'==========================================
\
n'
);
console
.
log
(
'==========================================
\
n'
);
}
}
/**
/**
*
获取父进程的 shell 路径
*
Get parent process shell path
*/
*/
function
getParentShell
()
{
function
getParentShell
()
{
try
{
try
{
const
parentPid
=
process
.
ppid
;
const
parentPid
=
process
.
ppid
;
if
(
isWindows
)
{
if
(
isWindows
)
{
// Windows:
使用 PowerShell 获取父进程信息
// Windows:
Get parent process info using PowerShell
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
exec
(
`wmic process where ProcessId=
${
parentPid
}
get ExecutablePath`
,
(
error
,
stdout
)
=>
{
exec
(
`wmic process where ProcessId=
${
parentPid
}
get ExecutablePath`
,
(
error
,
stdout
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'⚠️
无法获取父进程路径,使用默认
shell'
);
console
.
log
(
'⚠️
Could not get parent shell path, using default
shell'
);
resolve
(
null
);
resolve
(
null
);
return
;
return
;
}
}
const
lines
=
stdout
.
trim
().
split
(
'
\
n'
);
const
lines
=
stdout
.
trim
().
split
(
'
\
n'
);
if
(
lines
.
length
>=
2
)
{
if
(
lines
.
length
>=
2
)
{
const
parentPath
=
lines
[
1
].
trim
();
const
parentPath
=
lines
[
1
].
trim
();
//
检查是否是
PowerShell
//
Check if it's
PowerShell
if
(
parentPath
.
toLowerCase
().
includes
(
'powershell'
)
||
if
(
parentPath
.
toLowerCase
().
includes
(
'powershell'
)
||
parentPath
.
toLowerCase
().
includes
(
'pwsh'
))
{
parentPath
.
toLowerCase
().
includes
(
'pwsh'
))
{
resolve
(
parentPath
);
resolve
(
parentPath
);
...
@@ -98,11 +98,11 @@ function getParentShell() {
...
@@ -98,11 +98,11 @@ function getParentShell() {
});
});
});
});
}
else
{
}
else
{
// Unix:
通过 /proc/<pid>/exe 获取
// Unix:
Get via /proc/<pid>/exe
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
fs
.
readlink
(
`/proc/
${
parentPid
}
/exe`
,
(
error
,
link
)
=>
{
fs
.
readlink
(
`/proc/
${
parentPid
}
/exe`
,
(
error
,
link
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'⚠️
无法获取父进程路径,使用默认
shell'
);
console
.
log
(
'⚠️
Could not get parent shell path, using default
shell'
);
resolve
(
null
);
resolve
(
null
);
return
;
return
;
}
}
...
@@ -111,19 +111,19 @@ function getParentShell() {
...
@@ -111,19 +111,19 @@ function getParentShell() {
});
});
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
`⚠️
获取父进程 shell 失败
:
${
error
.
message
}
`
);
console
.
log
(
`⚠️
Failed to get parent shell
:
${
error
.
message
}
`
);
return
Promise
.
resolve
(
null
);
return
Promise
.
resolve
(
null
);
}
}
}
}
/**
/**
*
使用指定 shell 执行命令
*
Execute command using specified shell
*/
*/
function
execWithShell
(
command
,
shellPath
)
{
function
execWithShell
(
command
,
shellPath
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
options
=
{
const
options
=
{
shell
:
shellPath
||
true
,
shell
:
shellPath
||
true
,
env
:
process
.
env
,
//
继承当前进程的环境变量,包括
PATH
env
:
process
.
env
,
//
Inherit current process environment variables, including
PATH
windowsHide
:
true
windowsHide
:
true
};
};
...
@@ -148,10 +148,10 @@ async function executeCommand(command) {
...
@@ -148,10 +148,10 @@ async function executeCommand(command) {
try
{
try
{
parentShell
=
await
getParentShell
();
parentShell
=
await
getParentShell
();
if
(
parentShell
)
{
if
(
parentShell
)
{
console
.
log
(
`🔍
父进程
shell:
${
parentShell
}
`
);
console
.
log
(
`🔍
Parent
shell:
${
parentShell
}
`
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
//
忽略错误,使用默认
//
Ignore error, use default
}
}
}
}
...
@@ -298,7 +298,7 @@ async function installSs3ops() {
...
@@ -298,7 +298,7 @@ async function installSs3ops() {
async
function
main
()
{
async
function
main
()
{
console
.
log
(
'🚀 Starting environment check...
\
n'
);
console
.
log
(
'🚀 Starting environment check...
\
n'
);
//
打印环境变量信息
//
Print environment variables information
printEnvironmentInfo
();
printEnvironmentInfo
();
let
allChecksPassed
=
true
;
let
allChecksPassed
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment