mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-23 20:42:17 +00:00
build: include commit hash in version.txt
This commit is contained in:
parent
1ef1db30ab
commit
8d4194772e
@ -2,10 +2,13 @@
|
|||||||
import { readFileSync, writeFileSync } from 'node:fs';
|
import { readFileSync, writeFileSync } from 'node:fs';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { dirname } from 'node:path';
|
import { dirname } from 'node:path';
|
||||||
|
import { execSync } from 'node:child_process';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
|
const commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
|
||||||
|
|
||||||
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
|
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
|
||||||
const pkgVer = (pkgJson.version ?? 'unknown') + '\n';
|
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash ?? 'unknown'}` + '\n';
|
||||||
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');
|
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');
|
||||||
|
Loading…
Reference in New Issue
Block a user