unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import fs from 'fs'
2import path from 'path'
3import child_process from 'child_process'
4import packageJson from '../../../package.json'
5
6function execSyncSafe(command: string) {
7 let out = null
8 try {
9 out = child_process.execSync(command).toString().trim()
10 } catch (error) {
11 console.error(error)
12 }
13 return out
14}
15
16const isScript = require.main === module
17if (isScript) main()
18
19function main(): void {
20 // Load build data (git and stuff)
21 const buildData = {
22 version: packageJson.version,
23 git: {
24 branch: execSyncSafe('git rev-parse --abbrev-ref HEAD'),
25 hash: execSyncSafe('git rev-parse --short=7 HEAD'),
26 fullHash: execSyncSafe('git rev-parse HEAD'),
27 },
28 timestamp: new Date().getTime()
29 }
30
31 const filePath = path.resolve('src', 'buildData.json')
32 const fileContents = JSON.stringify(buildData)
33
34 fs.writeFileSync(filePath, fileContents)
35}