/* * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ const fs = require('fs'); const child_process = require('child_process'); const packageJsonPath = __dirname + '/../package.json' function build() { try { const gitDescribe = child_process.execSync('git describe --tags --always').toString().trim(); const gitCommit = child_process.execSync('git rev-parse HEAD').toString().trim(); const json = fs.readFileSync(packageJsonPath, 'utf-8') const meta = JSON.parse(json); fs.mkdirSync(__dirname + '/../built', { recursive: true }); fs.writeFileSync(__dirname + '/../built/meta.json', JSON.stringify( { version: meta.version, gitCommit: gitCommit, gitDescribe: gitDescribe, }), 'utf-8'); } catch (e) { console.error(e) } } build(); if (process.argv.includes("--watch")) { fs.watch(packageJsonPath, (event, filename) => { console.log(`update ${filename} ...`) build() }) }