22 lines
622 B
JavaScript
22 lines
622 B
JavaScript
// build-time.js
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// 生成当前时间的 yyyyMMdd 格式
|
|
const now = new Date();
|
|
const year = now.getFullYear();
|
|
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
const day = String(now.getDate()).padStart(2, '0');
|
|
const buildTime = `${year}${month}${day}`;
|
|
|
|
// 创建 JSON 对象
|
|
const buildData = {
|
|
buildTime: buildTime,
|
|
timestamp: now.toISOString()
|
|
};
|
|
|
|
// 写入文件
|
|
const filePath = path.join(__dirname, 'build.json');
|
|
fs.writeFileSync(filePath, JSON.stringify(buildData, null, 2));
|
|
|
|
console.log(`Build time ${buildTime} written to build.json`); |