Created
October 12, 2017 19:43
-
-
Save duduindo/e29d7c200086d51aadaba90ac32035d8 to your computer and use it in GitHub Desktop.
Eslint files from commit git
This file contains hidden or 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
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