mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-19 01:28:38 +02:00
test(utils, mdx-loader, core): improve coverage (#6303)
* test(utils, mdx-loader, core): improve coverage * windows... * fix
This commit is contained in:
parent
cf265c051e
commit
a79c23bc45
38 changed files with 841 additions and 219 deletions
|
@ -15,16 +15,17 @@ const MAX_PATH_SEGMENT_BYTES = 255;
|
|||
// Space for appending things to the string like file extensions and so on
|
||||
const SPACE_FOR_APPENDING = 10;
|
||||
|
||||
const isMacOs = process.platform === `darwin`;
|
||||
const isWindows = process.platform === `win32`;
|
||||
const isMacOs = () => process.platform === 'darwin';
|
||||
const isWindows = () => process.platform === 'win32';
|
||||
|
||||
export const isNameTooLong = (str: string): boolean =>
|
||||
isMacOs || isWindows
|
||||
// This is actually not entirely correct: we can't assume FS from OS. But good enough?
|
||||
isMacOs() || isWindows()
|
||||
? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
|
||||
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
||||
|
||||
export const shortName = (str: string): string => {
|
||||
if (isMacOs || isWindows) {
|
||||
if (isMacOs() || isWindows()) {
|
||||
const overflowingChars = str.length - MAX_PATH_SEGMENT_CHARS;
|
||||
return str.slice(
|
||||
0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue