refactor(utils): categorize functions into separate files (#6773)

This commit is contained in:
Joshua Chen 2022-02-26 21:17:21 +08:00 committed by GitHub
parent 908ad52025
commit 670f2e5268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 928 additions and 886 deletions

View file

@ -5,10 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
// Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
import path from 'path';
// Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
// MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
// Others = 255 bytes
const MAX_PATH_SEGMENT_CHARS = 255;
@ -113,3 +112,10 @@ export function escapePath(str: string): string {
// Remove the " around the json string;
return escaped.substring(1, escaped.length - 1);
}
export function addTrailingPathSeparator(str: string): string {
return str.endsWith(path.sep)
? str
: // If this is Windows, we need to change the forward slash to backward
`${str.replace(/\/$/, '')}${path.sep}`;
}