addAll
Add or update index entries matching files in the working directory.
Signature
class Index {
addAll(pathspecs: string[], options?: IndexAddAllOptions): void;
}
Parameters
- pathspecsrequired · string[]
A List of file names of shell glob patterns that will matched against files in the repository's working directory. Each file that matches will be added to the index (either updating an existing entry or adding a new entry).
- optionsnull | IndexAddAllOptions
Options for add or update index entries.
- checkPathspecboolean
To emulate
git add -A
and generate an error if the pathspec contains the exact path of an ignored file (when not usingforce
), add thecheckPathspec
flag. This checks that each entry inpathspecs
that is an exact match to a filename on disk is either not ignored or already in the index. If this check fails, the function will return an error. - disablePathspecMatchboolean
The
pathspecs
are a list of file names or shell glob patterns that will matched against files in the repository's working directory. Each file that matches will be added to the index (either updating an existing entry or adding a new entry). You can disable glob expansion and force exact matching with thedisablePathspecMatch
flag. - forceboolean
Files that are ignored will be skipped (unlike
addPath
). If a file is already tracked in the index, then it will be updated even if it is ignored. Pass theforce
flag to skip the checking of ignore rules. - onMatch(args: IndexOnMatchCallbackArgs) => number
If you provide a callback function, it will be invoked on each matching item in the working directory immediately before it is added to / updated in the index. Returning zero will add the item to the index, greater than zero will skip the item, and less than zero will abort the scan an return an error to the caller.
- checkPathspecboolean
Errors
- Error
This method will fail in bare index instances.
Examples
Emulate git add *
:
import { openRepository } from 'es-git';
const repo = await openRepository('.');
const index = repo.index();
index.addAll(['*']);
index.write();