mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
35 lines
591 B
TypeScript
35 lines
591 B
TypeScript
import { execSync } from 'child_process';
|
|
|
|
type GitUser = {
|
|
name?: string;
|
|
email?: string;
|
|
};
|
|
|
|
export function tryReadGitUser(): GitUser {
|
|
const user: GitUser = { name: '', email: '' };
|
|
|
|
try {
|
|
const name = execSync('git config --get user.name', {
|
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
})
|
|
.toString()
|
|
.trim();
|
|
if (name) user.name = name;
|
|
} catch {
|
|
// ignore
|
|
}
|
|
|
|
try {
|
|
const email = execSync('git config --get user.email', {
|
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
})
|
|
.toString()
|
|
.trim();
|
|
if (email) user.email = email;
|
|
} catch {
|
|
// ignore
|
|
}
|
|
|
|
return user;
|
|
}
|