fix: 配置生产

This commit is contained in:
ningmengchongshui 2024-06-15 08:27:06 +08:00
parent 1a84cafe53
commit 4fe35676f3
3 changed files with 27 additions and 25 deletions

View File

@ -1,28 +1,7 @@
import YAML from 'yaml'
import chokidar from 'chokidar'
import { join } from 'node:path'
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs'
import { CONFIG_DEFAULT_PATH, CONFIG_INIT_PATH } from './system.js'
/**
*
*/
export function configInit() {
const path = CONFIG_INIT_PATH
const pathDef = CONFIG_DEFAULT_PATH
const files = readdirSync(pathDef).filter(file => file.endsWith('.yaml'))
mkdirSync(join(process.cwd(), path), {
'recursive': true
})
for (const file of files) {
if (!existsSync(`${path}${file}`)) {
copyFileSync(`${pathDef}${file}`, `${path}${file}`)
}
}
if (!existsSync("data")) mkdirSync("data")
if (!existsSync("resources")) mkdirSync("resources")
}
import { readFileSync, } from 'node:fs'
/**
* ********
*

View File

@ -1,6 +1,6 @@
import './init/modules.js'
import './init/logger.js'
import './init/config.js'
import './init/logger.js'
import './init/redis.js'
import { promises } from 'node:fs'
import yaml from 'yaml'

View File

@ -1,2 +1,25 @@
import { configInit } from '../config/config.js'
configInit()
import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs'
import { CONFIG_DEFAULT_PATH, CONFIG_INIT_PATH } from '../config/system.js'
import { join } from 'node:path'
const path = CONFIG_INIT_PATH
const pathDef = CONFIG_DEFAULT_PATH
// 得到文件
const files = readdirSync(pathDef).filter(file => file.endsWith('.yaml'))
mkdirSync(join(process.cwd(), path), {
recursive: true
})
for (const file of files) {
if (!existsSync(`${path}${file}`)) {
copyFileSync(`${pathDef}${file}`, `${path}${file}`)
}
}
if (!existsSync('data')) {
mkdirSync('data', {
recursive: true
})
}
if (!existsSync('resources')) {
mkdirSync('resources', {
recursive: true
})
}