Skip to content

Commit

Permalink
Allow Github install without git
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Oct 31, 2022
1 parent dceb628 commit bd2cd19
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions build-plugins/get-banner.ts
Expand Up @@ -23,9 +23,14 @@ function generateBanner(commitHash: string, version: string): string {

let getBannerPromise: Promise<string> | null = null;

export default async function getBanner(): Promise<string> {
export default function getBanner(): Promise<string> {
return (getBannerPromise ||= Promise.all([
execPromise('git rev-parse HEAD'),
execPromise('git rev-parse HEAD')
.then(({ stdout }) => stdout.trim())
.catch(error => {
console.error('Could not determine commit hash:', error);
return 'unknown';
}),
fs.readFile(new URL('../package.json', import.meta.url), 'utf8')
]).then(([{ stdout }, package_]) => generateBanner(stdout.trim(), JSON.parse(package_).version)));
]).then(([commit, package_]) => generateBanner(commit, JSON.parse(package_).version)));
}

0 comments on commit bd2cd19

Please sign in to comment.