Skip to content

Instantly share code, notes, and snippets.

@akonwi
Last active November 13, 2015 04:44
Show Gist options
  • Save akonwi/68cec63c3a2e176f2c5e to your computer and use it in GitHub Desktop.
Save akonwi/68cec63c3a2e176f2c5e to your computer and use it in GitHub Desktop.
git.cmd = (args, options={}) ->
new Promise (resolve, reject) ->
output = ''
try
new BufferedProcess
command: atom.config.get('git-plus.gitPath') ? 'git'
args: args
options: options
stdout: (data) -> output += data.toString()
stderr: (data) -> reject data.toString()
exit: (code) -> resolve output
catch
notifier.addError 'Git Plus is unable to locate the git command. Please ensure process.env.PATH can access git.'
reject "Couldn't find git"
# New usage
stagedFiles = (repo) ->
args = ['diff-index', '--cached', 'HEAD', '--name-status', '-z']
git.cmd(args, cwd: repo.getWorkingDirectory())
.then (data) -> # handle data
.catch (error) -> # handle error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment