diff --git a/README.md b/README.md index 4aa4d47..70e05b5 100644 --- a/README.md +++ b/README.md @@ -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') diff --git a/lib/removeRemote.js b/lib/removeRemote.js index 87749be..cf9e0e9 100644 --- a/lib/removeRemote.js +++ b/lib/removeRemote.js @@ -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 = ' '; diff --git a/package.json b/package.json index ab4337d..0f1a471 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/removeRemote.js b/test/removeRemote.js index 9a1e32b..48cd39f 100644 --- a/test/removeRemote.js +++ b/test/removeRemote.js @@ -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(); + }); + }); + };