(...args)
| 124 | } |
| 125 | |
| 126 | export function join(...args) { |
| 127 | if (args.length === 0) return '.' |
| 128 | let joined |
| 129 | for (let i = 0; i < args.length; ++i) { |
| 130 | // Normalise separators before processing. |
| 131 | const arg = args[i].replace(/\\/g, '/') |
| 132 | if (arg.length === 0) continue |
| 133 | |
| 134 | // A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be |
| 135 | // meaningfully appended to any base, so it resets the accumulator. |
| 136 | // Unix absolute paths (leading '/') are NOT reset here — that would be |
| 137 | // path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'. |
| 138 | if (/^[a-zA-Z]:\//.test(arg)) { |
| 139 | joined = arg |
| 140 | } else { |
| 141 | if (joined === undefined) joined = arg |
| 142 | else joined += '/' + arg |
| 143 | } |
| 144 | } |
| 145 | if (joined === undefined) return '.' |
| 146 | return normalize(joined) |
| 147 | } |
searching dependent graphs…