git-last-commit
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "git-last-commit", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Read details of the last commit including tags", | ||
@@ -5,0 +5,0 @@ "main": "./source/index.js", |
@@ -8,3 +8,3 @@ # git-last-commit | ||
git.getLastCommit(function(commit) { | ||
git.getLastCommit(function(err, commit) { | ||
// read commit object properties | ||
@@ -38,1 +38,11 @@ console.log(commit); | ||
``` | ||
You can add path destination if you want to get git last commit information on another repository: | ||
```javascript | ||
var git = require('git-last-commit'); | ||
git.getLastCommit(function(err, commit) { | ||
// read commit object properties | ||
console.log(commit); | ||
}, {dst: 'some/other/path'}); | ||
``` |
@@ -1,5 +0,12 @@ | ||
var process = require('child_process'); | ||
var process = require('child_process'), | ||
options = {}; | ||
function _command(command, callback) { | ||
process.exec(command, {cwd: __dirname}, function(err, stdout, stderr) { | ||
var dst = __dirname; | ||
if(!!options && options.dst) { | ||
dst = options.dst; | ||
} | ||
process.exec(command, {cwd: dst}, function(err, stdout, stderr) { | ||
if (stdout === '') { | ||
@@ -25,3 +32,4 @@ callback('this does not look like a git repo'); | ||
module.exports = { | ||
getLastCommit : function(callback) { | ||
getLastCommit : function(callback, _options) { | ||
options = _options; | ||
_command(command, function(err, res) { | ||
@@ -28,0 +36,0 @@ if (err) { |
@@ -143,2 +143,15 @@ /*jshint expr: true*/ | ||
it('should run the git command on given destination', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\nR2\nR1'); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.equal('path/path/whatever'); | ||
done(); | ||
}, {dst: 'path/path/whatever'}); | ||
}); | ||
it('should handle error properly if this is not a git repo', function(done) { | ||
@@ -145,0 +158,0 @@ processExecMethod.yields(null, ''); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14080
254
46