HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/git-parse/dist/git_diff.js.flow
import promisify from 'util.promisify';
import childProcess from 'child_process';

const exec = promisify(childProcess.exec);

/**
 * Returns a git diff given a path to the repo, a commit,
 * an optional second commit, and an optional file.
 *
 * Returns the diff as a string.
 */
const gitDiff = (pathToRepo, commit1, commit2 = '', file = '') =>
  exec(`git diff ${commit1} ${commit2} -- ${file}`, {
    cwd: pathToRepo,
    encoding: 'utf8',
    maxBuffer: 1024 * 1000
  }).then(output => output.stdout);

export default gitDiff;