You can get an object stream of git staged files on git.
WIP: This gulp plugin is a work in progress.
- Add more test for this plugin.
You can get an object stream of git staged files on git.
First, install gulp-git-staged
as a development dependency:
npm install --save-dev gulp-git-staged
Then, add it to your gulpfile.js
:
var gitStaged = require("gulp-git-staged");
gulp.src("./src/*.ext")
.pipe(gitStaged())
.on('data', function (file) {
console.log("Staged file:", file);
});
Type: String
Default: AMRC
What status mode to look for.
A = added
M = modified
R = renamed
C = copied
We use this plugin for pre-commit task.
gulp.task('pre-commit', function(done) {
gulp.src('./**/*')
.pipe(gitStaged())
.pipe(jshint())
.pipe(jsbeautifier({
config: '.jsbeautifyrc',
mode: 'VERIFY_AND_WRITE'
}))
.pipe(gulp.dest('dest'))
.pipe(git.add());
});