Commit 2d79693e authored by Auto Backup's avatar Auto Backup

refactor: change all Chinese output to English in check-environment.js

parent 62567761
......@@ -15,31 +15,31 @@ const isLinux = os.platform() === 'linux';
console.log(`Platform: ${os.platform()} (${isWindows ? 'Windows' : isMacOS ? 'macOS' : isLinux ? 'Linux' : 'Other'})`);
/**
* 打印环境变量信息
* Print environment variables information
*/
function printEnvironmentInfo() {
console.log('\n==========================================');
console.log(' 当前环境变量信息');
console.log(' Environment Variables Information');
console.log('==========================================\n');
// 关键环境变量
// Key environment variables
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) {
if (process.env[key]) {
console.log(`${key}: ${process.env[key]}`);
}
}
console.log('\n🔍 PATH 详细内容:\n');
console.log('\n🔍 PATH Details:\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');
console.log('\n🔍 Node.js Related Environment Variables:\n');
const nodeVars = ['NODE', 'NODE_OPTIONS', 'npm_config_prefix', 'npm_config_cache', 'APPDATA', 'LOCALAPPDATA'];
for (const key of nodeVars) {
if (process.env[key]) {
......@@ -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'];
for (const key of gitVars) {
if (process.env[key]) {
......@@ -55,37 +55,37 @@ function printEnvironmentInfo() {
}
}
console.log('\n🔍 所有环境变量列表:\n');
console.log('\n🔍 All Environment Variables:\n');
const allEnvVars = Object.keys(process.env).sort();
allEnvVars.forEach((key) => {
console.log(` ${key} = ${process.env[key]}`);
});
console.log('\n==========================================');
console.log(' 环境变量打印完成');
console.log(' Environment Variables Dump Complete');
console.log('==========================================\n');
}
/**
* 获取父进程的 shell 路径
* Get parent process shell path
*/
function getParentShell() {
try {
const parentPid = process.ppid;
if (isWindows) {
// Windows: 使用 PowerShell 获取父进程信息
// Windows: Get parent process info using PowerShell
return new Promise((resolve) => {
exec(`wmic process where ProcessId=${parentPid} get ExecutablePath`, (error, stdout) => {
if (error) {
console.log('⚠️ 无法获取父进程路径,使用默认 shell');
console.log('⚠️ Could not get parent shell path, using default shell');
resolve(null);
return;
}
const lines = stdout.trim().split('\n');
if (lines.length >= 2) {
const parentPath = lines[1].trim();
// 检查是否是 PowerShell
// Check if it's PowerShell
if (parentPath.toLowerCase().includes('powershell') ||
parentPath.toLowerCase().includes('pwsh')) {
resolve(parentPath);
......@@ -98,11 +98,11 @@ function getParentShell() {
});
});
} else {
// Unix: 通过 /proc/<pid>/exe 获取
// Unix: Get via /proc/<pid>/exe
return new Promise((resolve) => {
fs.readlink(`/proc/${parentPid}/exe`, (error, link) => {
if (error) {
console.log('⚠️ 无法获取父进程路径,使用默认 shell');
console.log('⚠️ Could not get parent shell path, using default shell');
resolve(null);
return;
}
......@@ -111,19 +111,19 @@ function getParentShell() {
});
}
} catch (error) {
console.log(`⚠️ 获取父进程 shell 失败: ${error.message}`);
console.log(`⚠️ Failed to get parent shell: ${error.message}`);
return Promise.resolve(null);
}
}
/**
* 使用指定 shell 执行命令
* Execute command using specified shell
*/
function execWithShell(command, shellPath) {
return new Promise((resolve, reject) => {
const options = {
shell: shellPath || true,
env: process.env, // 继承当前进程的环境变量,包括 PATH
env: process.env, // Inherit current process environment variables, including PATH
windowsHide: true
};
......@@ -148,10 +148,10 @@ async function executeCommand(command) {
try {
parentShell = await getParentShell();
if (parentShell) {
console.log(`🔍 父进程 shell: ${parentShell}`);
console.log(`🔍 Parent shell: ${parentShell}`);
}
} catch (e) {
// 忽略错误,使用默认
// Ignore error, use default
}
}
......@@ -298,7 +298,7 @@ async function installSs3ops() {
async function main() {
console.log('🚀 Starting environment check...\n');
// 打印环境变量信息
// Print environment variables information
printEnvironmentInfo();
let allChecksPassed = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment