@docusaurus/utils 3.7.0-canary-6243 → 3.7.0-canary-6245
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.map +1 -1
- package/lib/gitUtils.js +14 -12
- package/lib/gitUtils.js.map +1 -1
- package/package.json +6 -6
- package/src/gitUtils.ts +13 -21
package/lib/gitUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,2DAA2D;AAC3D,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C,uEAAuE;AACvE,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AAEjD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB;AACrC,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,OAAO,CAAC;IACT,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AACH;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB;AACrC,iCAAiC;AACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ;;;OAGG;IACH,GAAG,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,aAAa,EAAE,IAAI,CAAC;CACrB,GACA,OAAO,CAAC;IACT,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC"}
|
package/lib/gitUtils.js
CHANGED
|
@@ -12,8 +12,15 @@ const tslib_1 = require("tslib");
|
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
14
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
15
|
-
const
|
|
16
|
-
const realHasGitFn = () =>
|
|
15
|
+
const execa_1 = tslib_1.__importDefault(require("execa"));
|
|
16
|
+
const realHasGitFn = () => {
|
|
17
|
+
try {
|
|
18
|
+
return execa_1.default.sync('git', ['--version']).exitCode === 0;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
17
24
|
// The hasGit call is synchronous IO so we memoize it
|
|
18
25
|
// The user won't install Git in the middle of a build anyway...
|
|
19
26
|
const hasGit = process.env.NODE_ENV === 'test' ? realHasGitFn : lodash_1.default.memoize(realHasGitFn);
|
|
@@ -43,17 +50,12 @@ async function getFileCommitDate(file, { age = 'oldest', includeAuthor = false,
|
|
|
43
50
|
.filter(Boolean)
|
|
44
51
|
.join(' ');
|
|
45
52
|
const command = `git -c log.showSignature=false log ${args} -- "${path_1.default.basename(file)}"`;
|
|
46
|
-
const result = await
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cwd: path_1.default.dirname(file),
|
|
50
|
-
silent: true,
|
|
51
|
-
}, (code, stdout, stderr) => {
|
|
52
|
-
resolve({ code, stdout, stderr });
|
|
53
|
-
});
|
|
53
|
+
const result = await (0, execa_1.default)(command, {
|
|
54
|
+
cwd: path_1.default.dirname(file),
|
|
55
|
+
shell: true,
|
|
54
56
|
});
|
|
55
|
-
if (result.
|
|
56
|
-
throw new Error(`Failed to retrieve the git history for file "${file}" with exit code ${result.
|
|
57
|
+
if (result.exitCode !== 0) {
|
|
58
|
+
throw new Error(`Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`);
|
|
57
59
|
}
|
|
58
60
|
// We only parse the output line starting with our "RESULT:" prefix
|
|
59
61
|
// See why https://github.com/facebook/docusaurus/pull/10022
|
package/lib/gitUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitUtils.js","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"gitUtils.js","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoFH,8CAkFC;;AApKD,wDAAwB;AACxB,gEAA0B;AAC1B,4DAAuB;AACvB,0DAA0B;AAE1B,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,IAAI,CAAC;QACH,OAAO,eAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,qDAAqD;AACrD,gEAAgE;AAChE,MAAM,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAE3E,2DAA2D;AAC3D,MAAa,gBAAiB,SAAQ,KAAK;CAAG;AAA9C,4CAA8C;AAE9C,uEAAuE;AACvE,MAAa,mBAAoB,SAAQ,KAAK;CAAG;AAAjD,kDAAiD;AA4D1C,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,EACE,GAAG,GAAG,QAAQ,EACd,aAAa,GAAG,KAAK,GAItB;IAMD,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACd,MAAM,IAAI,gBAAgB,C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,IAAI,2CAA2C,CAChG,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAElC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,gDAAgD,IAAI,6BAA6B,MAAM,EAAE,CAC1F,CAAC;IACJ,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,MAAO,CAAC,SAAS,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,kBAAkB,GAAG,IAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IAEjC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAO,CAAC,MAAO,EAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6245",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
22
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
23
|
-
"@docusaurus/utils-common": "3.7.0-canary-
|
|
21
|
+
"@docusaurus/logger": "3.7.0-canary-6245",
|
|
22
|
+
"@docusaurus/types": "3.7.0-canary-6245",
|
|
23
|
+
"@docusaurus/utils-common": "3.7.0-canary-6245",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
|
+
"execa": "5.1.1",
|
|
25
26
|
"file-loader": "^6.2.0",
|
|
26
27
|
"fs-extra": "^11.1.1",
|
|
27
28
|
"github-slugger": "^1.5.0",
|
|
@@ -33,7 +34,6 @@
|
|
|
33
34
|
"micromatch": "^4.0.5",
|
|
34
35
|
"prompts": "^2.4.2",
|
|
35
36
|
"resolve-pathname": "^3.0.0",
|
|
36
|
-
"shelljs": "^0.8.5",
|
|
37
37
|
"tslib": "^2.6.0",
|
|
38
38
|
"url-loader": "^4.1.1",
|
|
39
39
|
"utility-types": "^3.10.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"dedent": "^0.7.0",
|
|
51
51
|
"tmp-promise": "^3.0.3"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "65621de892b3c3b011c9888712803039301672c9"
|
|
54
54
|
}
|
package/src/gitUtils.ts
CHANGED
|
@@ -8,9 +8,15 @@
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from 'fs-extra';
|
|
10
10
|
import _ from 'lodash';
|
|
11
|
-
import
|
|
11
|
+
import execa from 'execa';
|
|
12
12
|
|
|
13
|
-
const realHasGitFn = () =>
|
|
13
|
+
const realHasGitFn = () => {
|
|
14
|
+
try {
|
|
15
|
+
return execa.sync('git', ['--version']).exitCode === 0;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
// The hasGit call is synchronous IO so we memoize it
|
|
16
22
|
// The user won't install Git in the middle of a build anyway...
|
|
@@ -123,27 +129,13 @@ export async function getFileCommitDate(
|
|
|
123
129
|
file,
|
|
124
130
|
)}"`;
|
|
125
131
|
|
|
126
|
-
const result = await
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
stderr: string;
|
|
130
|
-
}>((resolve) => {
|
|
131
|
-
shell.exec(
|
|
132
|
-
command,
|
|
133
|
-
{
|
|
134
|
-
// Setting cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
|
|
135
|
-
cwd: path.dirname(file),
|
|
136
|
-
silent: true,
|
|
137
|
-
},
|
|
138
|
-
(code, stdout, stderr) => {
|
|
139
|
-
resolve({code, stdout, stderr});
|
|
140
|
-
},
|
|
141
|
-
);
|
|
132
|
+
const result = await execa(command, {
|
|
133
|
+
cwd: path.dirname(file),
|
|
134
|
+
shell: true,
|
|
142
135
|
});
|
|
143
|
-
|
|
144
|
-
if (result.code !== 0) {
|
|
136
|
+
if (result.exitCode !== 0) {
|
|
145
137
|
throw new Error(
|
|
146
|
-
`Failed to retrieve the git history for file "${file}" with exit code ${result.
|
|
138
|
+
`Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`,
|
|
147
139
|
);
|
|
148
140
|
}
|
|
149
141
|
|