28 lines
782 B
JavaScript
Executable file
28 lines
782 B
JavaScript
Executable file
#!/bin/node
|
||
|
||
import fs from 'fs'
|
||
import path from 'path'
|
||
import process from 'process'
|
||
|
||
const Config = {
|
||
PORT: 8000,
|
||
DB: path.resolve(process.cwd(), 'db'),
|
||
WWW: path.resolve(process.cwd(), 'www')
|
||
}
|
||
|
||
if (fs.existsSync('config.json')) {
|
||
console.log('Найден файл config.json')
|
||
let json = JSON.parse(fs.readFileSync('config.json'));
|
||
|
||
Config.PORT = json.PORT || Config.PORT
|
||
Config.DB = json.DB || Config.DB
|
||
Config.WWW = json.WWW || Config.WWW
|
||
}
|
||
else
|
||
console.log('Файл config.json не найден. Конфигурация по умолчанию.')
|
||
|
||
console.log(`Порт: ${Config.PORT}`)
|
||
console.log(`База данных: ${Config.DB}`)
|
||
console.log(`Веб-контент: ${Config.WWW}`)
|
||
|
||
fs.writeFileSync('config.json', JSON.stringify(Config, null, 2))
|