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
5afdc415
Commit
5afdc415
authored
Mar 19, 2026
by
Auto Backup
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加环境变量打印功能,显示PATH和关键配置
parent
2b442278
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
check-environment.js
check-environment.js
+55
-0
No files found.
check-environment.js
View file @
5afdc415
...
@@ -14,6 +14,58 @@ const isLinux = os.platform() === 'linux';
...
@@ -14,6 +14,58 @@ 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'
}
)`
);
/**
* 打印环境变量信息
*/
function
printEnvironmentInfo
()
{
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
' 当前环境变量信息'
);
console
.
log
(
'==========================================
\
n'
);
// 关键环境变量
const
keyVars
=
[
'PATH'
,
'NODE_PATH'
,
'HOME'
,
'USER'
,
'USERNAME'
,
'TEMP'
,
'TMP'
,
'PROCESSOR_ARCHITECTURE'
,
'OS'
,
'PATHEXT'
,
'COMSPEC'
,
'SystemRoot'
];
console
.
log
(
'🔍 关键环境变量:
\
n'
);
for
(
const
key
of
keyVars
)
{
if
(
process
.
env
[
key
])
{
console
.
log
(
`
${
key
}
:
${
process
.
env
[
key
]}
`
);
}
}
console
.
log
(
'
\
n🔍 PATH 详细内容:
\
n'
);
const
pathSeparator
=
isWindows
?
';'
:
':'
;
const
pathDirs
=
(
process
.
env
.
PATH
||
''
).
split
(
pathSeparator
);
pathDirs
.
forEach
((
dir
,
index
)
=>
{
console
.
log
(
` [
${
index
+
1
}
]
${
dir
}
`
);
});
console
.
log
(
'
\
n🔍 Node.js 相关环境变量:
\
n'
);
const
nodeVars
=
[
'NODE'
,
'NODE_OPTIONS'
,
'npm_config_prefix'
,
'npm_config_cache'
,
'APPDATA'
,
'LOCALAPPDATA'
];
for
(
const
key
of
nodeVars
)
{
if
(
process
.
env
[
key
])
{
console
.
log
(
`
${
key
}
:
${
process
.
env
[
key
]}
`
);
}
}
console
.
log
(
'
\
n🔍 SSH 和 Git 相关环境变量:
\
n'
);
const
gitVars
=
[
'GIT_SSH'
,
'GIT_SSH_COMMAND'
,
'GIT_TERMINAL_PROMPT'
,
'SSH_AUTH_SOCK'
,
'SSH_AGENT_PID'
,
'GIT_EXEC_PATH'
];
for
(
const
key
of
gitVars
)
{
if
(
process
.
env
[
key
])
{
console
.
log
(
`
${
key
}
:
${
process
.
env
[
key
]}
`
);
}
}
console
.
log
(
'
\
n🔍 所有环境变量列表:
\
n'
);
const
allEnvVars
=
Object
.
keys
(
process
.
env
).
sort
();
allEnvVars
.
forEach
((
key
)
=>
{
console
.
log
(
`
${
key
}
=
${
process
.
env
[
key
]}
`
);
});
console
.
log
(
'
\
n=========================================='
);
console
.
log
(
' 环境变量打印完成'
);
console
.
log
(
'==========================================
\
n'
);
}
/**
/**
* 获取父进程的 shell 路径
* 获取父进程的 shell 路径
*/
*/
...
@@ -245,6 +297,9 @@ async function installSs3ops() {
...
@@ -245,6 +297,9 @@ async function installSs3ops() {
async
function
main
()
{
async
function
main
()
{
console
.
log
(
'🚀 Starting environment check...
\
n'
);
console
.
log
(
'🚀 Starting environment check...
\
n'
);
// 打印环境变量信息
printEnvironmentInfo
();
let
allChecksPassed
=
true
;
let
allChecksPassed
=
true
;
// Check Node.js
// Check Node.js
...
...
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