Skip to content

Instantly share code, notes, and snippets.

@duduindo
Created October 12, 2017 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duduindo/e29d7c200086d51aadaba90ac32035d8 to your computer and use it in GitHub Desktop.
Save duduindo/e29d7c200086d51aadaba90ac32035d8 to your computer and use it in GitHub Desktop.
Eslint files from commit git
const gulp = require('gulp');
const { spawnSync } = require('child_process');
/**
* Get files from commit
* {String} Hash commit
* {Regex} Regex filter extensions
*/
const getGitCommit = (hash, regex) => {
const spawn = spawnSync('git', ['diff-tree', '--no-commit-id', '--name-only', '-r', hash]);
let src = spawn.stdout.toString().split(/\s/g);
src = src.filter(value => value.match(regex) ? value : false);
return src;
};
/**
* Task eslint
*/
gulp.task('eslint', () => {
const hash = 'de8ee9a05fb4ea54e669b9fe3dddf38b06e94c45'; // Hash
const regex = /^resources\/[^\.]+\.(js|jsx|node)$/g; // Only src resources/.js|.jsx|.node
console.log(getGitCommit(hash, regex));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment