Skip to content

Instantly share code, notes, and snippets.

@caseyWebb
Last active December 29, 2016 00:14
Show Gist options
  • Save caseyWebb/12bddc5cb672cd364f0016092d0f47ce to your computer and use it in GitHub Desktop.
Save caseyWebb/12bddc5cb672cd364f0016092d0f47ce to your computer and use it in GitHub Desktop.
ESLint New/Changed Files (Gulp Task)
'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