Skip to content

Instantly share code, notes, and snippets.

@pi0
Last active November 18, 2019 14:48
Show Gist options
  • Save pi0/b5462317693bea6c0f019935791a1e8b to your computer and use it in GitHub Desktop.
Save pi0/b5462317693bea6c0f019935791a1e8b to your computer and use it in GitHub Desktop.
Get git commit in one line!
const gitCommit = process.env.GIT_COMMIT || require('child_process')
.spawnSync('git', ['rev-parse', '--short', 'HEAD'], { encoding: 'utf8' })
.stdout.slice(0, -1)
console.log(gitCommit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment