Skip to content

Commit

Permalink
fix double callbacks + missing cb check - closes #162 closes #159
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlacy committed May 31, 2017
1 parent 968f95d commit 167d083
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ gulp.task('reset', function(){
});
});

// Show the formatted git diff
gulp.task('diff', function(){
gulp.src('./*')
.pipe(git.diff('master', {log: true}))
.pipe(gulp.dest('./diff.out'));
});

// Git rm a file or folder
gulp.task('rm', function(){
return gulp.src('./gruntfile.js')
Expand Down
6 changes: 5 additions & 1 deletion lib/removeRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ module.exports = function (remote, opt, cb) {
cb = opt;
opt = {};
}
if (!remote || typeof remote !== 'string') {
var error = new Error('gulp-git: remote is required git.removeRemote("origin")');
if (!cb || typeof cb !== 'function') throw error;
return cb(error);
}
if (!cb || typeof cb !== 'function') cb = function () {};
if (!remote) cb(new Error('gulp-git: remote is required git.removeRemote("origin")'));
if (!opt) opt = {};
if (!opt.cwd) opt.cwd = process.cwd();
if (!opt.args) opt.args = ' ';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"scripts": {
"docs": "rimraf docs/* && jsdoc ./index.js ./lib --recurse --destination ./docs",
"pretest": "rimraf test/repo test/tmp && eslint ./index.js ./examples/ ./lib/ ./test/",
"test": "mocha --reporter spec --timeout 6000 test/main.js"
"lint": "rimraf test/repo test/tmp && eslint ./index.js ./examples/ ./lib/ ./test/",
"test": "mocha --reporter spec --timeout 6000 test/main.js && npm run lint"
},
"engines": {
"node": ">= 0.9.0"
Expand Down
8 changes: 8 additions & 0 deletions test/removeRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ module.exports = function(git) {
});
});

it('should return an error if no remote exists', function(done) {
var opt = {cwd: './test/repo/'};
git.removeRemote(opt, function(e) {
should(e.message).match('gulp-git: remote is required git.removeRemote("origin")');
done();
});
});

};

0 comments on commit 167d083

Please sign in to comment.