build: ensure get-version runs in the electron git checkout (#36128)

This commit is contained in:
Samuel Attard 2022-10-25 11:27:10 -07:00 коммит произвёл GitHub
Родитель 7ca2bb5f9c
Коммит b13f776d1b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -1,5 +1,5 @@
const { spawnSync } = require('child_process');
const rootPackageJson = require('../../package.json');
const path = require('path');
module.exports.getElectronVersion = () => {
// Find the nearest tag to the current HEAD
@ -11,7 +11,9 @@ module.exports.getElectronVersion = () => {
// The only difference in the "git describe" technique is that technically a commit can "change" it's version
// number if a tag is created / removed retroactively. i.e. the first time a commit is pushed it will be 1.2.3
// and after the tag is made rebuilding the same commit will result in it being 1.2.4
const output = spawnSync('git', ['describe', '--tags', '--abbrev=0']);
const output = spawnSync('git', ['describe', '--tags', '--abbrev=0'], {
cwd: path.resolve(__dirname, '..', '..')
});
if (output.status !== 0) {
console.error(output.stderr);
throw new Error('Failed to get current electron version');