2023-12-28 20:36:29 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { dirname } from 'node:path';
|
2023-12-28 20:38:45 +00:00
|
|
|
import { execSync } from 'node:child_process';
|
2023-12-28 20:36:29 +00:00
|
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
const __dirname = dirname(__filename);
|
|
|
|
|
2023-12-28 20:38:45 +00:00
|
|
|
const commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
|
|
|
|
|
2023-12-28 20:36:29 +00:00
|
|
|
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
|
2023-12-28 20:38:45 +00:00
|
|
|
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash ?? 'unknown'}` + '\n';
|
2023-12-28 20:36:29 +00:00
|
|
|
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');
|