(workspaceDir, input)
| 183 | } |
| 184 | |
| 185 | async function listDir(workspaceDir, input) { |
| 186 | const requestedPath = typeof input.path === 'string' && input.path ? input.path : '.' |
| 187 | const absolutePath = resolveWorkspacePath(workspaceDir, requestedPath) |
| 188 | const entries = await fs.readdir(absolutePath, { withFileTypes: true }) |
| 189 | |
| 190 | return { |
| 191 | ok: true, |
| 192 | path: toWorkspaceRelative(workspaceDir, absolutePath), |
| 193 | entries: entries |
| 194 | .slice(0, 200) |
| 195 | .map(entry => ({ |
| 196 | name: entry.name, |
| 197 | type: entry.isDirectory() ? 'directory' : entry.isFile() ? 'file' : 'other', |
| 198 | })), |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | async function readFile(workspaceDir, input) { |
| 203 | if (typeof input.path !== 'string' || !input.path) { |
no test coverage detected