Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Aug 26, 2022
1 parent 8fbb38d commit d03c069
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build-plugins/get-banner.ts
@@ -1,11 +1,11 @@
import { exec } from 'node:child_process';
import { promises as fs } from 'node:fs';
import { env } from 'node:process';
import { promisify } from 'node:util';
import { version } from '../package.json';

const execPromise = promisify(exec);

function generateBanner(commitHash: string): string {
function generateBanner(commitHash: string, version: string): string {
const date = new Date(
env.SOURCE_DATE_EPOCH ? 1000 * +env.SOURCE_DATE_EPOCH : Date.now()
).toUTCString();
Expand All @@ -24,7 +24,8 @@ function generateBanner(commitHash: string): string {
let getBannerPromise: Promise<string> | null = null;

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

0 comments on commit d03c069

Please sign in to comment.