Skip to content

Commit dd9eaf5

Browse files
committed
Gulp task to automate unit tests before add/commit/push
1 parent 71f4fe0 commit dd9eaf5

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

gulpfile.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,33 @@ gulp.task('test', function(done) {
162162
singleRun: true
163163
}, done).start();
164164
});
165+
166+
var git = require('gulp-git');
167+
var prompt = require('gulp-prompt');
168+
169+
// Run git add
170+
gulp.task('git add', ['test'], function() {
171+
return gulp.src('./')
172+
.pipe(git.add());
173+
});
174+
175+
// Run git commit
176+
gulp.task('git commit', ['test'], function() {
177+
var message;
178+
gulp.src('./', {buffer:false})
179+
.pipe(prompt.prompt({
180+
type: 'input',
181+
name: 'commit',
182+
message: 'Please enter commit message...'
183+
}, function(res) {
184+
message = res.commit;
185+
}))
186+
.pipe(git.commit(message));
187+
});
188+
189+
// Run git push
190+
gulp.task('git push', ['test'], function() {
191+
git.push('origin', 'master', function(err) {
192+
if (err) throw err;
193+
});
194+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"gulp": "^3.9.0",
3838
"gulp-bump": "^1.0.0",
3939
"gulp-insert": "^0.5.0",
40+
"gulp-prompt": "^0.1.2",
4041
"gulp-replace": "^0.5.4",
4142
"gulp-uglify": "^1.4.2",
4243
"gulp-watch": "^4.3.5",

0 commit comments

Comments
 (0)