From 6072e6c583dd9122ba670db555a075654a852e62 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 14 Mar 2024 00:24:19 +0000 Subject: Move git hash fetch to nuxt-prepare --- server.prepare.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 server.prepare.ts (limited to 'server.prepare.ts') diff --git a/server.prepare.ts b/server.prepare.ts new file mode 100644 index 0000000..a858e69 --- /dev/null +++ b/server.prepare.ts @@ -0,0 +1,22 @@ +import { execSync } from 'child_process'; +import { defineNuxtPrepareHandler } from 'nuxt-prepare/config' + +export default defineNuxtPrepareHandler(async () => { + const gitCommitHash = execSync('git rev-parse HEAD').toString().trim(); + const gitCommitHashShort = gitCommitHash.slice(0, 8); + const gitBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim(); + + return { + runtimeConfig: { + public: { + gitCommitHash: gitCommitHash, + gitCommitHashShort: gitCommitHashShort, + gitBranch: gitBranch + } + }, + + state: { + foo: 'bar', + }, + } +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2