forked from ferreiratiago/gulp-git-push
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (35 loc) · 1.24 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var map = require('map-stream');
var gutil = require('gulp-util');
var git = require('gulp-git');
var objectAssign = require('object-assign');
/**
* @param options {object} Module options
* @param options.repository {string?} The 'remote' repository for push operation, default: 'origin'
* @param options.refspec {string?} Specify what destination ref to update with what source object, default: 'HEAD'
* @param options.options {object?} Gulp-git options, default: '{ args: '--follow-tags' }'
*/
module.exports = function (options) {
'use strict';
var opt = {
repository: 'origin',
refspec: 'HEAD',
options: { args: '--follow-tags' }
};
objectAssign(opt, options);
function modifyContents(file, cb) {
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new Error('Streams not supported'), file);
}
git.push(opt.repository, opt.refspec, opt.options, function endHandler(error) {
if (error) {
return cb(new Error(error), file);
}
gutil.log(gutil.colors.green('Changes pushed to remote'));
return cb(null, file);
});
}
return map(modifyContents);
};