14 lines
351 B
JavaScript
14 lines
351 B
JavaScript
|
"use strict";
|
||
|
|
||
|
import fs from 'fs';
|
||
|
import path from 'path';
|
||
|
|
||
|
export default async function(git_dir) {
|
||
|
const gitId = await fs.promises.readFile(path.join(git_dir, "HEAD"), 'utf8');
|
||
|
if (gitId.indexOf(':') === -1)
|
||
|
return gitId;
|
||
|
|
||
|
const refPath = path.join(git_dir, gitId.substring(5).trim());
|
||
|
return await fs.promises.readFile(refPath, 'utf8');
|
||
|
}
|