From 771d246a96cd476fa9fddf600c532a28b2efd93a Mon Sep 17 00:00:00 2001 From: to-s Date: Mon, 19 Oct 2020 12:38:51 -0400 Subject: Substitute author and email by git config (#186) * Substitute author and email by git config * Upgraded version of typescript Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505813068 * Moved to CppDocGen.generateAuthorTag() Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505819542 * Update README.md Due to https://github.com/cschlosser/doxdocgen/pull/186#discussion_r505822908 * Update TestSetup.ts * Added tests * Changed return type to string Due to https://ci.appveyor.com/project/cschlosser/doxdocgen/builds/35818180#L566 Co-authored-by: Christoph Schlosser <2466365+cschlosser@users.noreply.github.com> --- src/GitConfig.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/GitConfig.ts (limited to 'src/GitConfig.ts') diff --git a/src/GitConfig.ts b/src/GitConfig.ts new file mode 100644 index 0000000..2a425f6 --- /dev/null +++ b/src/GitConfig.ts @@ -0,0 +1,30 @@ +import simpleGit, {ConfigValues, SimpleGit} from "simple-git"; + +export default class GitConfig { + private gitConfig: ConfigValues; + + public constructor() { + const git: SimpleGit = simpleGit(); + git.listConfig().then((result) => { + this.gitConfig = result.all; + }); + } + + /** git config --get user.name */ + get UserName(): string { + try { + return this.gitConfig["user.name"].toString(); + } catch (error) { + return ""; + } + } + + /** git config --get user.email */ + get UserEmail(): string { + try { + return this.gitConfig["user.email"].toString(); + } catch (error) { + return ""; + } + } +} -- cgit v1.2.3