(path: string)
| 17 | } |
| 18 | |
| 19 | export const normalizePath = (path: string): string => { |
| 20 | // Normalize the path by... |
| 21 | let normalizedPath = path; |
| 22 | |
| 23 | // ... adding a trailing slash if it doesn't have one. |
| 24 | // This is important since ls-tree won't return the contents |
| 25 | // of a directory if it doesn't have a trailing slash. |
| 26 | if (!normalizedPath.endsWith('/')) { |
| 27 | normalizedPath = `${normalizedPath}/`; |
| 28 | } |
| 29 | |
| 30 | // ... removing any leading slashes. This is needed since |
| 31 | // the path is relative to the repository's root, so we |
| 32 | // need a relative path. |
| 33 | if (normalizedPath.startsWith('/')) { |
| 34 | normalizedPath = normalizedPath.slice(1); |
| 35 | } |
| 36 | |
| 37 | return normalizedPath; |
| 38 | } |
| 39 | |
| 40 | export const compareFileTreeItems = (a: FileTreeItem, b: FileTreeItem): number => { |
| 41 | if (a.type !== b.type) { |
no outgoing calls
no test coverage detected