@@ -1,13 +1,28 @@
11 import { homedir } from "node:os";
22 import { join, relative } from "node:path";
33
4+function stripMatchingQuotes(value: string): string {
5+ if (value.length < 2) return value;
6+ const first = value[0];
7+ const last = value[value.length - 1];
8+ if ((first === '"' || first === "'") && first === last) {
9+ return value.slice(1, -1);
10+ }
11+ return value;
12+}
13+
14+function normalizePathInput(pathInput: string): string {
15+ return stripMatchingQuotes(pathInput.trim());
16+}
17+
418 export function resolvePath(cwdInput: string | undefined, pathInput: string) {
519 const cwd = cwdInput ?? process.cwd();
6- const expanded = pathInput.startsWith("~/")
7- ? join(homedir(), pathInput.slice(2))
8- : pathInput === "~"
20+ const normalizedInput = normalizePathInput(pathInput);
21+ const expanded = normalizedInput.startsWith("~/")
22+ ? join(homedir(), normalizedInput.slice(2))
23+ : normalizedInput === "~"
924 ? homedir()
10- : pathInput;
25+ : normalizedInput;
1126 const filePath = expanded.startsWith("/") ? expanded : join(cwd, expanded);
1227
1328 const relPath = relative(cwd, filePath);