summaryrefslogtreecommitdiffstats
path: root/src/GitConfig.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/GitConfig.ts')
-rw-r--r--src/GitConfig.ts30
1 files changed, 30 insertions, 0 deletions
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 "";
+ }
+ }
+}