fix: 配置生产
This commit is contained in:
parent
1a84cafe53
commit
4fe35676f3
|
@ -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'
|
||||
/**
|
||||
* ********
|
||||
* 配置文件
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue