Include Soapbox FE commit hash when git is available

merge-requests/461/head
Alex Gleason 2021-03-30 13:11:04 -05:00
rodzic f97bba2308
commit a032369d33
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 17 dodań i 1 usunięć

Wyświetl plik

@ -1,11 +1,27 @@
// @preval
const pkg = require('../../../package.json');
const { execSync } = require('child_process');
const shortRepoName = url => new URL(url).pathname.substring(1);
const version = pkg => {
try {
const head = String(execSync('git rev-parse HEAD'));
const tag = String(execSync(`git rev-parse v${pkg.version}`));
if (head !== tag) {
return `${pkg.version}-${head.substring(0, 7)}`;
} else {
return pkg.version;
}
} catch (e) {
return pkg.version;
}
};
module.exports = {
name: pkg.name,
url: pkg.repository.url,
repository: shortRepoName(pkg.repository.url),
version: pkg.version,
version: version(pkg),
};