Giter Site home page Giter Site logo

get-changed-files's Introduction

Get Changed Files

Get a list of changed files using git.

Install

npm intall get-changed-files --save-dev
yarn add get-changed-files --dev

API

Simple usage

Without any options get-changed-files assumes that master is the main branch to compare it against current branch and also uses default strategy for determining diff point (point in history from which to start getting changes).

const getChangedFiles = require("get-changed-files");
getChangedFiles().then(results => console.log(results));

/**
 * Outputs:
 * {
 *   "changed": [
 *     "some-old-changed-file.js",
 *     "package.json",
 *     "new-file.js"
 *   ],
 *   "uncommitted": [
 *     "package.json"
 *   ],
 *   "untracked": [
 *     "new-file.js"
 *   ]
 * }
 */

Changing main branch

const getChangedFiles = require("get-changed-files");
getChangedFiles({ mainBranch: "develop" }).then(results =>
  console.log(results)
);

Custom get diff point strategy

const getChangedFiles = require("get-changed-files");
const customGetDiffPoint = ({ currentBranch, mainBranch }) => {
  // do some magic...
  return { commit: commit_hash_from_which_to_start_getting_changes };
};
getChangedFiles({ customGetDiffPoint }).then(results => console.log(results));

CLI

Also get-changed-files adds a CLI tool get-changed.

get-changed --help

  Get a list of changed files

  Usage
    $ get-changed

  Options
    --branch, -b     Specify main branch [default: master].
    --only, -o       Specify subset of results to be printed e.g. โ€“ changed | uncommitted | untracked.
    --names          Output file names only without any formatting. Can't be used with --json.
    --json           Output result as json. Can't be used with --names-only.

  Examples
    $ get-changed --only=changed
    $ get-changed --json --only=changed
    $ get-changed --names-only

get-changed-files's People

Contributors

jackllllll avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.