Created
October 3, 2018 12:16
-
-
Save rigelk/5fb764856a56dfce96925f797943ff3d to your computer and use it in GitHub Desktop.
getVersion
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
async function getVersion () { | |
const tag = await require('child_process') | |
.exec('[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] }) | |
if (tag) return tag.replace(/^v/, '') | |
const version = await require('child_process') | |
.exec('[ ! -d .git ] || git rev-parse --short HEAD') | |
if (version) return version.toString().trim() | |
return require('../../../package.json').version | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment