(path: string, _depth = 0)
| 131 | } |
| 132 | |
| 133 | async realpath(path: string, _depth = 0): Promise<string> { |
| 134 | if (_depth > MAX_SYMLINK_DEPTH) { |
| 135 | throw new Error(`ELOOP: too many levels of symbolic links: ${path}`); |
| 136 | } |
| 137 | |
| 138 | const stat = await this.ws.lstat(path); |
| 139 | if (!stat) { |
| 140 | throw new Error(`ENOENT: no such file or directory: ${path}`); |
| 141 | } |
| 142 | |
| 143 | if (stat.type !== "symlink") { |
| 144 | return normalizePath(path); |
| 145 | } |
| 146 | |
| 147 | const target = await this.ws.readlink(path); |
| 148 | const resolved = target.startsWith("/") |
| 149 | ? normalizePath(target) |
| 150 | : normalizePath(`${dirname(path)}/${target}`); |
| 151 | return this.realpath(resolved, _depth + 1); |
| 152 | } |
| 153 | |
| 154 | resolvePath(base: string, path: string): string { |
| 155 | return normalizePath(path.startsWith("/") ? path : `${base}/${path}`); |
nothing calls this directly
no test coverage detected