mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 04:12:53 +02:00
fix(v2): only show the Git requirement message for the last update of docs plugin once (#1830)
This commit is contained in:
parent
4fe6ae3c24
commit
9692d4e6d7
1 changed files with 8 additions and 1 deletions
|
@ -11,6 +11,8 @@ type FileLastUpdateData = {timestamp?: number; author?: string};
|
||||||
|
|
||||||
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+), (.+)$/;
|
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+), (.+)$/;
|
||||||
|
|
||||||
|
let showedGitRequirementError = false;
|
||||||
|
|
||||||
export default function getFileLastUpdate(
|
export default function getFileLastUpdate(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
): FileLastUpdateData | null {
|
): FileLastUpdateData | null {
|
||||||
|
@ -32,9 +34,14 @@ export default function getFileLastUpdate(
|
||||||
// Wrap in try/catch in case the shell commands fail (e.g. project doesn't use Git, etc).
|
// Wrap in try/catch in case the shell commands fail (e.g. project doesn't use Git, etc).
|
||||||
try {
|
try {
|
||||||
if (!shell.which('git')) {
|
if (!shell.which('git')) {
|
||||||
console.log('Sorry, the docs plugin last update options require Git.');
|
if (!showedGitRequirementError) {
|
||||||
|
showedGitRequirementError = true;
|
||||||
|
console.log('Sorry, the docs plugin last update options require Git.');
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To differentiate between content change and file renaming/moving, use --summary
|
// To differentiate between content change and file renaming/moving, use --summary
|
||||||
// To follow the file history until before it is moved (when we create new version), use
|
// To follow the file history until before it is moved (when we create new version), use
|
||||||
// --follow.
|
// --follow.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue