From 07cda150cd82f8bfad634b789bff5fd6782e0def Mon Sep 17 00:00:00 2001 From: Patryk Ziemkowski Date: Mon, 25 Sep 2023 12:48:48 +0200 Subject: [PATCH] fix: Set version to 0.0.1 when git is unable to determine a version in case no tags exist in repository (#402) --- packages/internal/cli/src/config/env.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/internal/cli/src/config/env.ts b/packages/internal/cli/src/config/env.ts index c2606fac3..a2b13e05d 100644 --- a/packages/internal/cli/src/config/env.ts +++ b/packages/internal/cli/src/config/env.ts @@ -33,9 +33,16 @@ export async function loadVersionEnv() { return process.env.VERSION; } - const { stdout: versionRaw } = await exec( - 'git describe --tags --first-parent --abbrev=11 --long --dirty --always', - ); + let versionRaw = ''; + try { + const { stdout } = await exec( + 'git describe --tags --first-parent --abbrev=11 --long --dirty --always', + ); + versionRaw = stdout; + } catch { + versionRaw = '0.0.1'; + } + const version = versionRaw.trim(); process.env.VERSION = version; return version;