summaryrefslogtreecommitdiff
path: root/packages/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src')
-rw-r--r--packages/server/src/utils/paths.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/server/src/utils/paths.ts b/packages/server/src/utils/paths.ts
index 4ff74897..bbd479fd 100644
--- a/packages/server/src/utils/paths.ts
+++ b/packages/server/src/utils/paths.ts
@@ -5,6 +5,20 @@
*/
import path from 'node:path';
+import os from 'os';
+
+/**
+ * Replaces the home directory with a tilde.
+ * @param path - The path to tildeify.
+ * @returns The tildeified path.
+ */
+export function tildeifyPath(path: string): string {
+ const homeDir = os.homedir();
+ if (path.startsWith(homeDir)) {
+ return path.replace(homeDir, '~');
+ }
+ return path;
+}
/**
* Shortens a path string if it exceeds maxLen, prioritizing the start and end segments.