( ignoreErrors: 'all' | 'pathspec' | 'none' = 'none', )
| 258 | } |
| 259 | |
| 260 | async function remove( |
| 261 | ignoreErrors: 'all' | 'pathspec' | 'none' = 'none', |
| 262 | ): Promise<(void | Response<void>)[]> { |
| 263 | const input = getInput('remove'); |
| 264 | if (!input) return []; |
| 265 | |
| 266 | const parsed = parseInputArray(input); |
| 267 | const res: (void | Response<void>)[] = []; |
| 268 | |
| 269 | for (const args of parsed) { |
| 270 | res.push( |
| 271 | // Push the result of every git command (which are executed in order) to the array |
| 272 | // If any of them fails, the whole function will return a Promise rejection |
| 273 | await git |
| 274 | .rm(matchGitArgs(args), (e, d) => |
| 275 | log(ignoreErrors === 'all' ? null : e, d), |
| 276 | ) |
| 277 | .catch((e: Error) => { |
| 278 | // if I should ignore every error, return |
| 279 | if (ignoreErrors === 'all') return; |
| 280 | |
| 281 | // if it's a pathspec error... |
| 282 | if ( |
| 283 | e.message.includes('fatal: pathspec') && |
| 284 | e.message.includes('did not match any files') |
| 285 | ) { |
| 286 | if (ignoreErrors === 'pathspec') return; |
| 287 | |
| 288 | const peh = getInput('pathspec_error_handling'), |
| 289 | err = new Error( |
| 290 | `Remove command did not match any file:\n git rm ${args}`, |
| 291 | ); |
| 292 | if (peh === 'exitImmediately') throw err; |
| 293 | if (peh === 'exitAtEnd') exitErrors.push(err); |
| 294 | } else throw e; |
| 295 | }), |
| 296 | ); |
| 297 | } |
| 298 | |
| 299 | return res; |
| 300 | } |
no test coverage detected