How to use the staged-git-files.cwd function in staged-git-files

To help you get started, we’ve selected a few staged-git-files examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github x-orpheus / elint / src / walker / stage.js View on Github external
function getStagedFileList (patterns, ignorePatterns) {
  const baseDir = getBaseDir()

  // 如果 baseDir 根本不存在 sgf 会抛出异常
  if (!fs.existsSync(baseDir)) {
    return Promise.resolve([])
  }

  sgf.cwd = baseDir

  return new Promise(resolve => {
    sgf((err, result) => {
      if (err) {
        debug('staged-git-files error: %o', err)
        return resolve([])
      }

      const fileList = result
        .filter(item => item.status !== 'Deleted') // 过滤已删除的文件
        .filter(item => match(item.filename, patterns, ignorePatterns))
        .map(item => item.filename)

      resolve(fileList)
    })
  })
github floatdrop / vinyl-git / sources / staged.js View on Github external
module.exports = function (options) {
    var stream = through.obj();

    sgf.cwd = process.cwd();

    sgf(function(err, results) {
        if (err) { return stream.emit('error', err); }

        var files = results.map(function (file) {
            return file.filename;
        });

        if (files.length === 0) {
            return stream.end();
        }

        fs.src(files, options).pipe(stream);
    });

    return stream;
github Tencent / feflow / lib / internal / lint / linter.js View on Github external
function getStageFiles(cb) {
  const gitDir = findParentDir.sync(process.cwd(), '.git');
  sgf.cwd = gitDir
  let stageFiles = [];
  sgf('ACM', (err, files) => {
    if (files) {
      stageFiles = files.map(item => {
        return item.filename
      })
    }
    cb(err, stageFiles);
  });
}

staged-git-files

get a list of staged git files and their status

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular staged-git-files functions