diff --git a/lib/tags.js b/lib/tags.js index 30dfda3..699a297 100644 --- a/lib/tags.js +++ b/lib/tags.js @@ -1,8 +1,24 @@ // Packages const semVer = require('semver'); const taggedVersions = require('tagged-versions'); - -const defaultRev = 'HEAD --first-parent `git rev-parse --abbrev-ref HEAD`'; +const childProcess = require('child-process-promise'); + +let defaultRev = 'HEAD --first-parent '; + +runCommand('git rev-parse --abbrev-ref HEAD').then((output) => { + defaultRev += output; +}) + +/** + * Run shell command and resolve with stdout content + * + * @param {string} command Shell command + * @return {Promise} + */ +function runCommand(command) { + return childProcess.exec(command) + .then(result => result.stdout); +} const defaultOptions = { rev: defaultRev, diff --git a/package.json b/package.json index 9bbdedc..6e23b4b 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "semver": "5.5.0", "tagged-versions": "1.3.0", "then-sleep": "1.0.1", - "update-check": "1.3.2" + "update-check": "1.3.2", + "child-process-promise": "^2.1.3" }, "eslintConfig": { "extends": [