Skip to content

Instantly share code, notes, and snippets.

@7rulnik
Created July 3, 2018 09:34
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 7rulnik/64d848abb9d5606abe42001f13578843 to your computer and use it in GitHub Desktop.
Save 7rulnik/64d848abb9d5606abe42001f13578843 to your computer and use it in GitHub Desktop.
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