added --commit-sha

vibrancy
antelle 2020-12-30 18:12:28 +01:00
parent 33763ab865
commit 014b6b2319
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 13 additions and 3 deletions

View File

@ -34,9 +34,19 @@ module.exports = function (grunt) {
const getCodeSignConfig = () =>
skipSign ? { identities: {} } : require('./keys/codesign.json');
const sha = fs.existsSync('.git')
? execSync('git rev-parse --short HEAD').toString('utf8').trim()
: '000';
let sha = grunt.option('commit-sha');
if (!sha) {
try {
sha = execSync('git rev-parse --short HEAD').toString('utf8').trim();
} catch (e) {
grunt.warn(
`Cannot get commit sha from git (${e.message}). It's recommended to build KeeWeb from a git repo ` +
'because commit sha is displayed in the UI, however if you would like to build from a folder, ' +
'you can override what will be displayed in the UI with --commit-sha=xxx'
);
}
}
grunt.log.writeln(`Building KeeWeb v${pkg.version} (${sha})`);
const webpackOptions = {
date,