thelounge/src/command-line/start.js
Reto d4cc2dd361
Refactor config out of Helper (#4558)
* Remove config from Helper

Helper is the usual util grab bag of useful stuff.
Somehow the config ended up there historically but
structurally that doesn't make any sense.

* Add cert folder to prettier ignore file
2022-05-01 12:12:39 -07:00

36 lines
985 B
JavaScript

"use strict";
const log = require("../log");
const colors = require("chalk");
const fs = require("fs");
const path = require("path");
const program = require("commander");
const Config = require("../config");
const Utils = require("./utils");
program
.command("start")
.description("Start the server")
.option("--dev", "Development mode with hot module reloading")
.on("--help", Utils.extraHelp)
.action(function (options) {
initalizeConfig();
const server = require("../server");
server(options);
});
function initalizeConfig() {
if (!fs.existsSync(Config.getConfigPath())) {
fs.mkdirSync(Config.getHomePath(), {recursive: true});
fs.chmodSync(Config.getHomePath(), "0700");
fs.copyFileSync(
path.resolve(path.join(__dirname, "..", "..", "defaults", "config.js")),
Config.getConfigPath()
);
log.info(`Configuration file created at ${colors.green(Config.getConfigPath())}.`);
}
fs.mkdirSync(Config.getUsersPath(), {recursive: true, mode: 0o700});
}