add method

Future<void> add(
  1. String pathSpec
)

Implementation

Future<void> add(String pathSpec) async {
  pathSpec = normalizePath(pathSpec);

  var index = await indexStorage.readIndex();

  var stat = await fs.stat(pathSpec);
  if (stat.type == FileSystemEntityType.file) {
    await addFileToIndex(index, pathSpec);
  } else if (stat.type == FileSystemEntityType.directory) {
    await addDirectoryToIndex(index, pathSpec, recursive: true);
  } else {
    throw Exception('Neither file or directory');
  }

  await indexStorage.writeIndex(index);
}