Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(vite): make read git branch call async (#2793)

Aidan Holloway-Bidwellc8eb4e311a28
diff --git a/js/app/packages/app/vite.base.ts b/js/app/packages/app/vite.base.ts
index 2e3d6feb98..e98aa4ac0a 100644
--- a/js/app/packages/app/vite.base.ts
+++ b/js/app/packages/app/vite.base.ts
@@ -1,4 +1,4 @@
-import { execSync } from 'node:child_process';
+import { execSync, exec } from 'node:child_process';
import { resolve } from 'node:path';
import tailwind from '@tailwindcss/vite';
import chokidar from 'chokidar';
@@ -31,6 +31,14 @@ function readGitBranch(): string {
}
}
+function readGitBranchAsync(): Promise<string> {
+ return new Promise((res) => {
+ exec('git rev-parse --abbrev-ref HEAD', (err, stdout) => {
+ res(err ? '' : stdout.trim());
+ });
+ });
+}
+
function gitBranchHmrPlugin(): Plugin {
return {
name: 'git-branch-hmr',
@@ -57,10 +65,12 @@ function gitBranchHmrPlugin(): Plugin {
});
});
server.ws.on('connection', () => {
- server.ws.send({
- type: 'custom',
- event: 'git-branch:update',
- data: readGitBranch(),
+ readGitBranchAsync().then((branch) => {
+ server.ws.send({
+ type: 'custom',
+ event: 'git-branch:update',
+ data: branch,
+ });
});
});
server.httpServer?.once('close', () => void watcher.close());