Skip to content

Commit 167d083

Browse files
committed
fix double callbacks + missing cb check - closes #162 closes #159
1 parent 968f95d commit 167d083

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ gulp.task('reset', function(){
253253
});
254254
});
255255

256+
// Show the formatted git diff
257+
gulp.task('diff', function(){
258+
gulp.src('./*')
259+
.pipe(git.diff('master', {log: true}))
260+
.pipe(gulp.dest('./diff.out'));
261+
});
262+
256263
// Git rm a file or folder
257264
gulp.task('rm', function(){
258265
return gulp.src('./gruntfile.js')

lib/removeRemote.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ module.exports = function (remote, opt, cb) {
1010
cb = opt;
1111
opt = {};
1212
}
13+
if (!remote || typeof remote !== 'string') {
14+
var error = new Error('gulp-git: remote is required git.removeRemote("origin")');
15+
if (!cb || typeof cb !== 'function') throw error;
16+
return cb(error);
17+
}
1318
if (!cb || typeof cb !== 'function') cb = function () {};
14-
if (!remote) cb(new Error('gulp-git: remote is required git.removeRemote("origin")'));
1519
if (!opt) opt = {};
1620
if (!opt.cwd) opt.cwd = process.cwd();
1721
if (!opt.args) opt.args = ' ';

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
},
2626
"scripts": {
2727
"docs": "rimraf docs/* && jsdoc ./index.js ./lib --recurse --destination ./docs",
28-
"pretest": "rimraf test/repo test/tmp && eslint ./index.js ./examples/ ./lib/ ./test/",
29-
"test": "mocha --reporter spec --timeout 6000 test/main.js"
28+
"lint": "rimraf test/repo test/tmp && eslint ./index.js ./examples/ ./lib/ ./test/",
29+
"test": "mocha --reporter spec --timeout 6000 test/main.js && npm run lint"
3030
},
3131
"engines": {
3232
"node": ">= 0.9.0"

test/removeRemote.js

+8
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ module.exports = function(git) {
1818
});
1919
});
2020

21+
it('should return an error if no remote exists', function(done) {
22+
var opt = {cwd: './test/repo/'};
23+
git.removeRemote(opt, function(e) {
24+
should(e.message).match('gulp-git: remote is required git.removeRemote("origin")');
25+
done();
26+
});
27+
});
28+
2129
};

0 commit comments

Comments
 (0)