Skip to content

Instantly share code, notes, and snippets.

@pstaender
Last active December 17, 2015 18:49
Show Gist options
  • Save pstaender/5655733 to your computer and use it in GitHub Desktop.
Save pstaender/5655733 to your computer and use it in GitHub Desktop.
{exec} = require('child_process')
version_hash = null
exec 'git rev-parse HEAD', (err,output) ->
# get revision hash from git and strip whitespaces
version_hash = if output then output.replace(/\s/g, '') else null
# uesed as default for mongoose
versionHash = -> version_hash
# use in your mongoose schema
user = new Schema
name: String
email:
type: String
index: true
version:
type: String
default: versionHash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment