@docusaurus/utils 0.0.0-5847 → 0.0.0-5848

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/lib/gitUtils.d.ts CHANGED
@@ -30,12 +30,12 @@ file: string, args: {
30
30
  age?: 'oldest' | 'newest';
31
31
  /** Use `includeAuthor: true` to get the author information as well. */
32
32
  includeAuthor?: false;
33
- }): {
33
+ }): Promise<{
34
34
  /** Relevant commit date. */
35
35
  date: Date;
36
36
  /** Timestamp in **seconds**, as returned from git. */
37
37
  timestamp: number;
38
- };
38
+ }>;
39
39
  /**
40
40
  * Fetches the git history of a file and returns a relevant commit date.
41
41
  * It gets the commit date instead of author date so that amended commits
@@ -55,12 +55,12 @@ file: string, args: {
55
55
  */
56
56
  age?: 'oldest' | 'newest';
57
57
  includeAuthor: true;
58
- }): {
58
+ }): Promise<{
59
59
  /** Relevant commit date. */
60
60
  date: Date;
61
61
  /** Timestamp in **seconds**, as returned from git. */
62
62
  timestamp: number;
63
63
  /** The author's name, as returned from git. */
64
64
  author: string;
65
- };
65
+ }>;
66
66
  //# sourceMappingURL=gitUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,2DAA2D;AAC3D,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C,uEAAuE;AACvE,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AAEjD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB;AAC/B,iCAAiC;AACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ;;;OAGG;IACH,GAAG,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,uEAAuE;IACvE,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,GACA;IACD,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,sDAAsD;IACtD,SAAS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AC;IAClB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC"}
package/lib/gitUtils.js CHANGED
@@ -18,7 +18,7 @@ exports.GitNotFoundError = GitNotFoundError;
18
18
  class FileNotTrackedError extends Error {
19
19
  }
20
20
  exports.FileNotTrackedError = FileNotTrackedError;
21
- function getFileCommitDate(file, { age = 'oldest', includeAuthor = false, }) {
21
+ async function getFileCommitDate(file, { age = 'oldest', includeAuthor = false, }) {
22
22
  if (!shelljs_1.default.which('git')) {
23
23
  throw new GitNotFoundError(`Failed to retrieve git history for "${file}" because git is not installed.`);
24
24
  }
@@ -32,10 +32,14 @@ function getFileCommitDate(file, { age = 'oldest', includeAuthor = false, }) {
32
32
  ]
33
33
  .filter(Boolean)
34
34
  .join(' ');
35
- const result = shelljs_1.default.exec(`git log ${args} -- "${path_1.default.basename(file)}"`, {
36
- // Setting cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
37
- cwd: path_1.default.dirname(file),
38
- silent: true,
35
+ const result = await new Promise((resolve) => {
36
+ shelljs_1.default.exec(`git log ${args} -- "${path_1.default.basename(file)}"`, {
37
+ // Setting cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
38
+ cwd: path_1.default.dirname(file),
39
+ silent: true,
40
+ }, (code, stdout, stderr) => {
41
+ resolve({ code, stdout, stderr });
42
+ });
39
43
  });
40
44
  if (result.code !== 0) {
41
45
  throw new Error(`Failed to retrieve the git history for file "${file}" with exit code ${result.code}: ${result.stderr}`);
@@ -1 +1 @@
1
- {"version":3,"file":"gitUtils.js","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,8DAA4B;AAE5B,2DAA2D;AAC3D,MAAa,gBAAiB,SAAQ,KAAK;CAAG;AAA9C,4CAA8C;AAE9C,uEAAuE;AACvE,MAAa,mBAAoB,SAAQ,KAAK;CAAG;AAAjD,kDAAiD;AA2DjD,SAAgB,iBAAiB,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BAA6B,MAAM,EAAE,CAC1F,CAAC;KACH;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAO,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAExC,IAAI,aAAa,EAAE;QACjB,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAO,CAAC,MAAO,EAAC,CAAC;KACzD;IACD,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;AAC3B,CAAC;AArFD,8CAqFC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/utils",
3
- "version": "0.0.0-5847",
3
+ "version": "0.0.0-5848",
4
4
  "description": "Node utility functions for Docusaurus packages.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/logger": "0.0.0-5847",
21
+ "@docusaurus/logger": "0.0.0-5848",
22
22
  "@svgr/webpack": "^6.5.1",
23
23
  "escape-string-regexp": "^4.0.0",
24
24
  "file-loader": "^6.2.0",
@@ -41,7 +41,7 @@
41
41
  "node": ">=18.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@docusaurus/types": "0.0.0-5847",
44
+ "@docusaurus/types": "0.0.0-5848",
45
45
  "@types/dedent": "^0.7.0",
46
46
  "@types/github-slugger": "^1.3.0",
47
47
  "@types/micromatch": "^4.0.2",
@@ -57,5 +57,5 @@
57
57
  "optional": true
58
58
  }
59
59
  },
60
- "gitHead": "a819e55b3b147c8ca2c1483813cc9c0ce2b75500"
60
+ "gitHead": "e96ac1a4796aa654d6a6c200f785fb4059619718"
61
61
  }
package/src/gitUtils.ts CHANGED
@@ -24,7 +24,7 @@ export class FileNotTrackedError extends Error {}
24
24
  * @throws Also throws when `git log` exited with non-zero, or when it outputs
25
25
  * unexpected text.
26
26
  */
27
- export function getFileCommitDate(
27
+ export async function getFileCommitDate(
28
28
  /** Absolute path to the file. */
29
29
  file: string,
30
30
  args: {
@@ -36,12 +36,12 @@ export function getFileCommitDate(
36
36
  /** Use `includeAuthor: true` to get the author information as well. */
37
37
  includeAuthor?: false;
38
38
  },
39
- ): {
39
+ ): Promise<{
40
40
  /** Relevant commit date. */
41
41
  date: Date;
42
42
  /** Timestamp in **seconds**, as returned from git. */
43
43
  timestamp: number;
44
- };
44
+ }>;
45
45
  /**
46
46
  * Fetches the git history of a file and returns a relevant commit date.
47
47
  * It gets the commit date instead of author date so that amended commits
@@ -52,7 +52,7 @@ export function getFileCommitDate(
52
52
  * @throws Also throws when `git log` exited with non-zero, or when it outputs
53
53
  * unexpected text.
54
54
  */
55
- export function getFileCommitDate(
55
+ export async function getFileCommitDate(
56
56
  /** Absolute path to the file. */
57
57
  file: string,
58
58
  args: {
@@ -63,15 +63,16 @@ export function getFileCommitDate(
63
63
  age?: 'oldest' | 'newest';
64
64
  includeAuthor: true;
65
65
  },
66
- ): {
66
+ ): Promise<{
67
67
  /** Relevant commit date. */
68
68
  date: Date;
69
69
  /** Timestamp in **seconds**, as returned from git. */
70
70
  timestamp: number;
71
71
  /** The author's name, as returned from git. */
72
72
  author: string;
73
- };
74
- export function getFileCommitDate(
73
+ }>;
74
+
75
+ export async function getFileCommitDate(
75
76
  file: string,
76
77
  {
77
78
  age = 'oldest',
@@ -80,11 +81,11 @@ export function getFileCommitDate(
80
81
  age?: 'oldest' | 'newest';
81
82
  includeAuthor?: boolean;
82
83
  },
83
- ): {
84
+ ): Promise<{
84
85
  date: Date;
85
86
  timestamp: number;
86
87
  author?: string;
87
- } {
88
+ }> {
88
89
  if (!shell.which('git')) {
89
90
  throw new GitNotFoundError(
90
91
  `Failed to retrieve git history for "${file}" because git is not installed.`,
@@ -105,11 +106,24 @@ export function getFileCommitDate(
105
106
  .filter(Boolean)
106
107
  .join(' ');
107
108
 
108
- const result = shell.exec(`git log ${args} -- "${path.basename(file)}"`, {
109
- // Setting cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
110
- cwd: path.dirname(file),
111
- silent: true,
109
+ const result = await new Promise<{
110
+ code: number;
111
+ stdout: string;
112
+ stderr: string;
113
+ }>((resolve) => {
114
+ shell.exec(
115
+ `git log ${args} -- "${path.basename(file)}"`,
116
+ {
117
+ // Setting cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
118
+ cwd: path.dirname(file),
119
+ silent: true,
120
+ },
121
+ (code, stdout, stderr) => {
122
+ resolve({code, stdout, stderr});
123
+ },
124
+ );
112
125
  });
126
+
113
127
  if (result.code !== 0) {
114
128
  throw new Error(
115
129
  `Failed to retrieve the git history for file "${file}" with exit code ${result.code}: ${result.stderr}`,