Skip to content

Commit

Permalink
Merge pull request #4667 from w33ble/fix/staged-linting
Browse files Browse the repository at this point in the history
Fix linting of staged files
  • Loading branch information
spalger committed Aug 13, 2015
2 parents bbfba96 + 2d43d1c commit 3a8b664
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tasks/lintStagedFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ module.exports = function (grunt) {
diff(['--name-only', '--cached'])
.then(function (files) {
// match these patterns
var patterns = grunt.config.get('eslint.files.src');
files = files.split('\n').filter(Boolean).map(function (file) {
var patterns = grunt.config.get('eslint.source.files.src');
if (!patterns) grunt.fail.warn('eslint file pattern is not defined');

files = files.split('\n').filter(Boolean)
.map(function (file) {
return resolve(root, file);
})
.filter(function (file) {
return grunt.file.isMatch(patterns, file);
});

files = grunt.file.match(patterns, files);
grunt.log.debug(files);

grunt.log.ok('Staged files to lint: ' + files.length);
if (!_.size(files)) return;

grunt.config.set('eslint.staged.files.src', files);
grunt.task.run(['eslint:staged']);
})
Expand Down

0 comments on commit 3a8b664

Please sign in to comment.