mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
refactor LAST_UPDATE_UNTRACKED_GIT_FILEPATH
This commit is contained in:
parent
2366ca16bf
commit
cf016c69f5
|
|
@ -13,6 +13,7 @@ import {
|
|||
getFileCommitDate,
|
||||
} from './vcs/gitUtils';
|
||||
import {DEFAULT_VCS_CONFIG} from './vcs/vcs';
|
||||
import {VCS_HARDCODED_UNTRACKED_FILE_PATH} from './vcs/vcsHardcoded';
|
||||
import type {PluginOptions, VcsConfig} from '@docusaurus/types';
|
||||
|
||||
export type LastUpdateData = {
|
||||
|
|
@ -79,8 +80,10 @@ export const LAST_UPDATE_FALLBACK: LastUpdateData = {
|
|||
lastUpdatedBy: 'Author',
|
||||
};
|
||||
|
||||
// Not proud of this, but convenient for tests :/
|
||||
export const LAST_UPDATE_UNTRACKED_GIT_FILEPATH = `file/path/${Math.random()}.mdx`;
|
||||
// TODO Docusaurus v4
|
||||
// should be removed in favor of using the hardcoded VSC impl/constant directly
|
||||
export const LAST_UPDATE_UNTRACKED_GIT_FILEPATH =
|
||||
VCS_HARDCODED_UNTRACKED_FILE_PATH;
|
||||
|
||||
export async function getLastUpdate(
|
||||
filePath: string,
|
||||
|
|
|
|||
|
|
@ -7,16 +7,18 @@
|
|||
|
||||
import type {VcsConfig, VcsChangeInfo} from '@docusaurus/types';
|
||||
|
||||
export const VCS_CHANGE_HARDCODED_CREATION_INFO: VcsChangeInfo = {
|
||||
export const VCS_HARDCODED_CREATION_INFO: VcsChangeInfo = {
|
||||
timestamp: 1490997600000, // 1st Apr 2017
|
||||
author: 'Creator',
|
||||
};
|
||||
|
||||
export const VCS_CHANGE_HARDCODED_LAST_UPDATE_INFO: VcsChangeInfo = {
|
||||
export const VCS_HARDCODED_LAST_UPDATE_INFO: VcsChangeInfo = {
|
||||
timestamp: 1539502055000, // 14th Oct 2018
|
||||
author: 'Author',
|
||||
};
|
||||
|
||||
export const VCS_HARDCODED_UNTRACKED_FILE_PATH = `file/path/${Math.random()}.mdx`;
|
||||
|
||||
/**
|
||||
* This VCS implementation always returns hardcoded values for testing purposes.
|
||||
* It is also useful in dev environments where VCS info is not important.
|
||||
|
|
@ -27,11 +29,17 @@ export const VcsHardcoded: VcsConfig = {
|
|||
// Noop
|
||||
},
|
||||
|
||||
getFileCreationInfo: async (_filePath: string) => {
|
||||
return VCS_CHANGE_HARDCODED_CREATION_INFO;
|
||||
getFileCreationInfo: async (filePath: string) => {
|
||||
if (filePath === VCS_HARDCODED_UNTRACKED_FILE_PATH) {
|
||||
return null;
|
||||
}
|
||||
return VCS_HARDCODED_CREATION_INFO;
|
||||
},
|
||||
|
||||
getFileLastUpdateInfo: async (_filePath: string) => {
|
||||
return VCS_CHANGE_HARDCODED_LAST_UPDATE_INFO;
|
||||
getFileLastUpdateInfo: async (filePath: string) => {
|
||||
if (filePath === VCS_HARDCODED_UNTRACKED_FILE_PATH) {
|
||||
return null;
|
||||
}
|
||||
return VCS_HARDCODED_LAST_UPDATE_INFO;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue