(opts: RmWithDeps)
| 164 | } |
| 165 | |
| 166 | export async function rmWith(opts: RmWithDeps): Promise<void> { |
| 167 | const dir = opts.dir ?? "/"; |
| 168 | for (const filepath of opts.paths) { |
| 169 | try { |
| 170 | await opts.git.remove({ fs: opts.fs, dir, filepath, cache: opts.cache }); |
| 171 | } catch (cause) { |
| 172 | if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause }); |
| 173 | if (looksLikePathspecMiss(cause)) { |
| 174 | throw new PathspecNotFoundError(filepath, { cause }); |
| 175 | } |
| 176 | throw new GitError("ERMFAIL", `git rm failed: ${errorMessage(cause)}`, { cause }); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | function looksLikePathspecMiss(cause: unknown): boolean { |
| 182 | if (!(cause instanceof Error)) return false; |
no test coverage detected