Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/compile/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Version } from '@pi-base/core'
import type { Version } from '@pi-base/core'
import { execFile } from 'node:child_process'
import { resolve } from 'node:path'
import { promisify } from 'node:util'

import { readFile } from './fs.js'

Expand Down Expand Up @@ -31,10 +33,12 @@ async function fromRepo(root = '.'): Promise<Version | undefined> {
const head = refName(contents)

if (head) {
const sha = await readFile(resolve(root, '.git', 'refs', 'heads', head))
const { stdout } = await promisify(execFile)('git', ['rev-parse', 'HEAD'], {
cwd: root,
})
return {
ref: head,
sha: sha.trim(),
sha: stdout.trim(),
}
}
}
Expand Down
Loading