git-er-done 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/git/getGitRoot.js +10 -5
- package/src/index.js +9 -0
- package/types/index.d.ts +6 -0
package/package.json
CHANGED
package/src/git/getGitRoot.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
const { executeCommand } = require('./utils/exec')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {Map<string, string>} */
|
|
4
|
+
const gitRootCache = new Map()
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Gets the root directory of the git repository
|
|
6
8
|
* @returns {Promise<string>} A promise that resolves to the root directory path of the git repository
|
|
7
9
|
*/
|
|
8
10
|
function getGitRoot() {
|
|
9
11
|
return new Promise((resolve, reject) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const cwd = process.cwd()
|
|
13
|
+
const cached = gitRootCache.get(cwd)
|
|
14
|
+
if (cached) {
|
|
15
|
+
return resolve(cached)
|
|
12
16
|
}
|
|
13
17
|
executeCommand('git rev-parse --show-toplevel', (err, res) => {
|
|
14
18
|
if (err) return reject(err)
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
const root = res.trim()
|
|
20
|
+
gitRootCache.set(cwd, root)
|
|
21
|
+
resolve(root)
|
|
17
22
|
})
|
|
18
23
|
})
|
|
19
24
|
}
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,15 @@ const {
|
|
|
14
14
|
getFileDates
|
|
15
15
|
} = require('./git/dates/getFileDates')
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import('./types').AuthorInfo} AuthorInfo
|
|
19
|
+
* @typedef {import('./types').CommitterInfo} CommitterInfo
|
|
20
|
+
* @typedef {import('./types').CommitInfo} CommitInfo
|
|
21
|
+
* @typedef {import('./types').FileMatchResult} FileMatchResult
|
|
22
|
+
* @typedef {import('./types').GitDetails} GitDetails
|
|
23
|
+
* @typedef {import('./types').FileDateInfo} FileDateInfo
|
|
24
|
+
*/
|
|
25
|
+
|
|
17
26
|
module.exports = {
|
|
18
27
|
// Get Git Details
|
|
19
28
|
gitDetails,
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export type AuthorInfo = import("./types").AuthorInfo;
|
|
2
|
+
export type CommitterInfo = import("./types").CommitterInfo;
|
|
3
|
+
export type CommitInfo = import("./types").CommitInfo;
|
|
4
|
+
export type FileMatchResult = import("./types").FileMatchResult;
|
|
5
|
+
export type GitDetails = import("./types").GitDetails;
|
|
6
|
+
export type FileDateInfo = import("./types").FileDateInfo;
|
|
1
7
|
import { gitDetails } from "./git/getDetails";
|
|
2
8
|
import { getGitRoot } from "./git/getGitRoot";
|
|
3
9
|
import { getCurrentBranch } from "./git/getCurrentBranch";
|