Last active
December 29, 2016 00:14
-
-
Save caseyWebb/12bddc5cb672cd364f0016092d0f47ce to your computer and use it in GitHub Desktop.
ESLint New/Changed Files (Gulp Task)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const spawn = require('cross-spawn') | |
const byline = require('byline') | |
const gulp = require('gulp') | |
const eslint = require('gulp-eslint') | |
module.exports = (done) => { | |
const diff = spawn('git', ['--no-pager', 'diff', '--cached', '--name-only', '*.js']) | |
const scripts = [] | |
diff.stdout | |
.pipe(byline.createStream()) | |
.on('data', (buffer) => scripts.push('./' + buffer.toString())) | |
.on('end', () => | |
gulp.src(scripts) | |
.pipe(eslint()) | |
.pipe(eslint.format()) | |
.pipe(eslint.failAfterError()) | |
.on('end', done)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment