1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 12:11:39 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

update hvigorfile.ts file (#463)

This commit is contained in:
波仔糕
2025-01-07 14:20:13 +08:00
committed by GitHub
parent 0df8261acb
commit 22d80890e2

View File

@@ -1,6 +1,7 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import fs from 'fs';
import path from 'path';
export function generatePushyBuildTime(str?: string) {
return {
pluginId: 'PushyBuildTimePlugin',
@@ -13,11 +14,22 @@ export function generatePushyBuildTime(str?: string) {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}
const moduleJsonPath = path.resolve(__dirname, './oh-package.json5');
let versionName = '';
if (fs.existsSync(moduleJsonPath)) {
const moduleContent = fs.readFileSync(moduleJsonPath, 'utf-8');
const versionMatch = moduleContent.match(/"version":\s*"([^"]+)"/);
if (versionMatch && versionMatch[1]) {
versionName = versionMatch[1];
}
}
const buildTime = new Date().toISOString();
const metaContent = { pushy_build_time : buildTime };
const metaContent = {
pushy_build_time: buildTime,
versionName: versionName
};
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
console.log(`Build time written to ${metaFilePath}`);
},
dependencies: [],
postDependencies: ['default@BuildJS']