From b13f776d1bc31fd909d995b235b48122d2e6b177 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 25 Oct 2022 11:27:10 -0700 Subject: [PATCH] build: ensure get-version runs in the electron git checkout (#36128) --- script/lib/get-version.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/lib/get-version.js b/script/lib/get-version.js index 06f156a049dd..b5496ec1d5d7 100644 --- a/script/lib/get-version.js +++ b/script/lib/get-version.js @@ -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');