Skip to content

joakimbeng/git-affected-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-affected-files

Build status NPM version XO code style

Get affected files in a git commit

Installation

Install git-affected-files using npm:

npm install --save git-affected-files

Usage

Module usage

const gitAffectedFiles = require('git-affected-files');

// Get affected files for last commit
gitAffectedFiles()
	.then(files => {
		console.log(files);
		/*
		  [
		    {status: 'A', filename: 'a/new/file'},
		    {status: 'M', filename: 'a/modified/file'},
		    {status: 'D', filename: 'a/deleted/file'},
		  ]
		*/
	});
	
// Get affected files for specific commit:
gitAffectedFiles('6ba8b08')
	.then(files => {
		console.log(files);
		/*
		  [
		    {status: 'A', filename: '.editorconfig'},
		    {status: 'A', filename: '.gitignore'},
		    ...
		  ]
		*/
	});

API

gitAffectedFiles([hash] [, options])

Name Type Description
hash String Git commit sha hash string
options Object Provided options are passed to execa, used to set cwd and similar

Returns: Promise<Array<Object>>

License

MIT © Joakim Carlstein