From 34f4d0abf49a770741366ba0c070eec6f903ef14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 16 Apr 2018 00:19:25 +0200 Subject: [PATCH] Add project version in outputs that mention source SHA --- src/helper.js | 3 ++- test/src/helperTest.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/helper.js b/src/helper.js index d4f00fd3..d477afe6 100644 --- a/src/helper.js +++ b/src/helper.js @@ -51,7 +51,8 @@ Helper.config = require(path.resolve(path.join( function getVersion() { const gitCommit = getGitCommit(); - return gitCommit ? `source (${gitCommit})` : `v${pkg.version}`; + const version = `v${pkg.version}`; + return gitCommit ? `source (${gitCommit} / ${version})` : version; } let _gitCommit; diff --git a/test/src/helperTest.js b/test/src/helperTest.js index 36d1b518..e7cd33c1 100644 --- a/test/src/helperTest.js +++ b/test/src/helperTest.js @@ -36,4 +36,20 @@ describe("Helper", function() { expect(Helper.expandHome(undefined)).to.equal(""); }); }); + + describe("#getVersion()", function() { + const version = Helper.getVersion(); + + it("should mention it is served from source code", function() { + expect(version).to.include("source"); + }); + + it("should include a short Git SHA", function() { + expect(version).to.match(/\([0-9a-f]{7,11} /); + }); + + it("should include a valid semver version", function() { + expect(version).to.match(/v[0-9]+\.[0-9]+\.[0-9]+/); + }); + }); });