(opts: AddWithDeps)
| 73 | } |
| 74 | |
| 75 | export async function addWith(opts: AddWithDeps): Promise<void> { |
| 76 | const dir = opts.dir ?? "/"; |
| 77 | if (opts.all) { |
| 78 | return addAll(opts, dir); |
| 79 | } |
| 80 | if (opts.paths.length === 0) return; |
| 81 | try { |
| 82 | // isomorphic-git 1.27+ accepts an array; older versions only |
| 83 | // accept a single string. We pass the array and let it fan |
| 84 | // out; the version pinned by the repo (^1.x) supports this. |
| 85 | await opts.git.add({ |
| 86 | fs: opts.fs, |
| 87 | dir, |
| 88 | filepath: opts.paths, |
| 89 | cache: opts.cache, |
| 90 | force: opts.force, |
| 91 | }); |
| 92 | } catch (cause) { |
| 93 | if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause }); |
| 94 | if (looksLikePathspecMiss(cause)) { |
| 95 | throw new PathspecNotFoundError(firstPathspec(opts.paths), { cause }); |
| 96 | } |
| 97 | throw new GitError("EADDFAIL", `git add failed: ${errorMessage(cause)}`, { cause }); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Stage every working-tree change. Walks the status matrix and |
no test coverage detected