1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const file = require('./utils/file')
- const { logger, fileLogger } = require("./utils/logger");
- const fs = require('fs');
- const path = require('path');
- /**
- * 配置
- * */
- let rustConfig = {}
- function init() {
- /**
- * 1. 检查目录
- * */
- getConfig()
- logger.info('--配置 检查完成');
- }
- function getConfig() {
- const configFilePath = path.join(__dirname, './utils/node.json');
- // 使用 fs 模块同步地读取 JSON 文件的内容
- try {
- // 读取文件内容
- const rawContent = fs.readFileSync(configFilePath, 'utf8');
- // 解析 JSON 内容为 JavaScript 对象
- const config = JSON.parse(rawContent);
- rustConfig = config.rustConfig
- // 现在可以访问 config 对象中的数据了
- logger.info('配置文件内容:',rawContent);
- } catch (error) {
- // 如果有错误发生,比如文件不存在或者 JSON 格式不正确,打印错误信息
- logger.error('读取配置文件时出错:', error);
- }
- }
- function getRustConfig(){
- return rustConfig
- }
- // 检查目录,与文件
- function checkConfig(id) {
- var appPath = path + "/" + id
- //1. 检查目录
- file.checkPath(appPath)
- //2. 检查文件
- for (var i in fileArray) {
- if (file.checkFilePath(appPath + "/" + fileArray[i])) {
- } else {
- //不存在,需要下载,比对版本号等
- }
- }
- }
- module.exports = {
- init,
- checkConfig,
- getRustConfig
- }
|