aboutsummaryrefslogtreecommitdiffstats
path: root/server.prepare.ts
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2024-03-14 00:24:19 +0000
committerLeonardo Bishop <me@leonardobishop.com>2024-03-14 00:24:19 +0000
commit6072e6c583dd9122ba670db555a075654a852e62 (patch)
treeead89df29d1efb2a9f60b4bed8dec41ce9b38050 /server.prepare.ts
parente1ff3b44a55349dad8c07de690ca86c984c91469 (diff)
Move git hash fetch to nuxt-prepare
Diffstat (limited to 'server.prepare.ts')
-rw-r--r--server.prepare.ts22
1 files changed, 22 insertions, 0 deletions
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