Skip to content

Commit

Permalink
Don't use bashisms in child_process.exec
Browse files Browse the repository at this point in the history
  • Loading branch information
eush77 committed Jan 12, 2016
1 parent 1d0f2f6 commit 8dc201d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ exports.dirty = function (repo, cb) {
}

exports.branch = function (repo, cb) {
exec('git show-ref &> /dev/null && git rev-parse --abbrev-ref HEAD', { cwd: repo }, function (err, stdout, stderr) {
exec('git show-ref >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD', { cwd: repo }, function (err, stdout, stderr) {
if (err) return cb() // most likely the git repo doesn't have any commits yet
cb(null, stdout.trim())
})
}

exports.ahead = function (repo, cb) {
exec('git show-ref &> /dev/null && git rev-list HEAD --not --remotes', { cwd: repo }, function (err, stdout, stderr) {
exec('git show-ref >/dev/null 2>&1 && git rev-list HEAD --not --remotes', { cwd: repo }, function (err, stdout, stderr) {
if (err) return cb(null, NaN) // depending on the state of the git repo, the command might return non-0 exit code
stdout = stdout.trim()
cb(null, !stdout ? 0 : parseInt(stdout.split(os.EOL).length, 10))
Expand Down

0 comments on commit 8dc201d

Please sign in to comment.