Files
n8n-enterprise-unlocked/packages/@n8n/node-cli/src/utils/git.ts

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;
}