1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 07:01:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
Files
react-native-update/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts
波仔糕 822602add9 react-native-pushy适配harmony (#461)
* init

* update

* udpate

* update

* update

* update

* add pushy build time logic
2024-12-26 12:11:52 +08:00

33 lines
1.3 KiB
TypeScript

import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import fs from 'fs';
import path from 'path';
export function generatePushyBuildTime(str?: string) {
return {
pluginId: 'PushyBuildTimePlugin',
apply(pluginContext) {
pluginContext.registerTask({
name: 'pushy_build_time',
run: (taskContext) => {
const metaFilePath = path.resolve(__dirname, 'src/main/resources/rawfile/meta.json');
const dirPath = path.dirname(metaFilePath);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}
const buildTime = new Date().toISOString();
const metaContent = { pushy_build_time : buildTime };
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
console.log(`Build time written to ${metaFilePath}`);
},
dependencies: [],
postDependencies: ['default@BuildJS']
})
}
}
}
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */
}