0

I currently run the following git command for list of all untracked and modified files:

git ls-files -mo --exclude-standard

Is there any equivalent for it in the NodeGit world?

mike
  • 1,233
  • 1
  • 15
  • 36
nitishagar
  • 9,038
  • 3
  • 28
  • 40

1 Answers1

0

This is one of the ways, I got around to satisfy the above requirement:

const Git = require("nodegit");
const _ = require("lodash");


function getDirtyFiles(path) {

    Git.Repository.open(path).then(function (repository) {
        repository.getStatus().then(function(statusFiles) {
            const dirtyFiles = _.chain(statusFiles)
            .filter((statusFile) => (statusFile.isModified() || statusFile.isNew()))
            .flatMap((statusDirtyFile) => statusDirtyFile.path())
            .value();
            
            console.log(dirtyFiles);
        });
    });
};

getDirtyFiles(process.cwd());

The following line helps match -mo params: statusFile.isModified() || statusFile.isNew()

nitishagar
  • 9,038
  • 3
  • 28
  • 40