mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-25 06:56:40 +07:00
improve vscode launching
This commit is contained in:
parent
4bc8b89b78
commit
31af4e11b1
10 changed files with 252 additions and 76 deletions
|
@ -2,20 +2,21 @@ import yaml from "js-yaml";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { Config } from "./types";
|
||||
import { mergeRight } from "ramda";
|
||||
import { validateConfig } from "./validate";
|
||||
import { getCmdArg } from "../utils/args";
|
||||
import { defaultConfig } from "./default";
|
||||
import { merge } from "lodash";
|
||||
|
||||
const configPath = getCmdArg("config");
|
||||
const defaultConfig = yaml.load<Config>(
|
||||
fs.readFileSync(path.join(__dirname, "../config.example.yml"), "utf8")
|
||||
);
|
||||
const userConfig = yaml.load<Config>(
|
||||
fs.readFileSync(configPath || path.join(__dirname, "../config.yml"), "utf8")
|
||||
const data = fs.readFileSync(
|
||||
configPath || path.join(__dirname, "../config.yml"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const userConfig = yaml.load(data) as Config;
|
||||
|
||||
const config =
|
||||
(userConfig && mergeRight(defaultConfig, userConfig)) || defaultConfig;
|
||||
(userConfig && merge(defaultConfig, userConfig)) || defaultConfig;
|
||||
|
||||
export default function prepareConfig() {
|
||||
validateConfig(config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue