Skip to content

Commit

Permalink
add commit to version when PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Jenkinson committed Jan 27, 2019
1 parent a8f99c4 commit f69bf3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/set-package-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ try {
if (!matched) {
throw new Error('Error calculating version.');
}
newVersion += `-${TRAVIS_MODE === 'netlifyPr' ? 'pr' : 'canary'}.${getCommitNum()}`;
if (TRAVIS_MODE === 'netlifyPr') {
newVersion += `-pr.${getCommitHash().substr(0, 8)}`;
} else {
newVersion += `-canary.${getCommitNum()}`;
}
} else {
throw new Error('Unsupported travis mode: ' + TRAVIS_MODE);
}
Expand All @@ -52,6 +56,10 @@ function getCommitNum() {
return parseInt(require('child_process').execSync('git rev-list --count HEAD').toString(), 10);
}

function getCommitHash() {
return require('child_process').execSync('git rev-parse HEAD').toString();
}

function getLatestVersionTag() {
return require('child_process').execSync('git describe --abbrev=0 --match="v*"').toString().trim();
}

0 comments on commit f69bf3e

Please sign in to comment.