Created
July 3, 2018 09:34
-
-
Save 7rulnik/64d848abb9d5606abe42001f13578843 to your computer and use it in GitHub Desktop.
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 childProcess = require('child_process') | |
const type = process.argv[2] | |
const currentBranch = 'git branch' | |
const diff = 'git diff --name-only --diff-filter=ACMTUXB origin/develop...HEAD' | |
const filter = `${diff} | grep app/.*\\.${type === 'css' ? 'sss$' : 'js$ | grep -v json'}` | |
const lint = type === 'css' ? 'stylelint $LIST --syntax sugarss' : 'eslint $LIST' | |
const condition = `if [ "$LIST" ]; then ./node_modules/.bin/${lint}; fi` | |
const command = [currentBranch, filter, `LIST=\`${filter}\``, condition].join('; ') | |
childProcess.exec(command, (err, stdout) => { | |
console.error(stdout) | |
if (err) { | |
process.exit(1) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment