mirror of
https://github.com/thelounge/thelounge
synced 2024-11-27 06:20:26 +00:00
Merge pull request #201 from VShell/config-outside-source
Refactor to move config to Shout home by default
This commit is contained in:
commit
cb4b6786b2
7 changed files with 31 additions and 13 deletions
|
@ -187,7 +187,3 @@ module.exports = {
|
|||
certificate: ""
|
||||
}
|
||||
};
|
||||
|
||||
if ("SHOUT_CONFIG" in process.env) {
|
||||
module.exports = require(process.env.SHOUT_CONFIG);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var _ = require("lodash");
|
||||
var config = require("../config");
|
||||
var Chan = require("./models/chan");
|
||||
var crypto = require("crypto");
|
||||
var log = require("./log");
|
||||
|
@ -8,6 +7,8 @@ var Msg = require("./models/msg");
|
|||
var Network = require("./models/network");
|
||||
var slate = require("slate-irc");
|
||||
var tls = require("tls");
|
||||
var Helper = require("./helper");
|
||||
var config = Helper.getConfig();
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var program = require("commander");
|
||||
var mkdirp = require("mkdirp");
|
||||
var child = require("child_process");
|
||||
var Helper = require("../helper");
|
||||
|
||||
var CONFIG_PATH = process.cwd() + "/config.js";
|
||||
var CONFIG_PATH = process.env.SHOUT_CONFIG;
|
||||
if(!CONFIG_PATH) {
|
||||
CONFIG_PATH = Helper.resolveHomePath("config.js");
|
||||
}
|
||||
if(!fs.exists(CONFIG_PATH)) {
|
||||
mkdirp.sync(Helper.getHomeDirectory());
|
||||
var configFile = fs.readFileSync(path.resolve(__dirname, "..", "..", "config.js"));
|
||||
fs.writeFileSync(CONFIG_PATH, configFile);
|
||||
}
|
||||
|
||||
program
|
||||
.command("config")
|
||||
.description("Edit config: '" + CONFIG_PATH + "'")
|
||||
.action(function() {
|
||||
child.spawn(
|
||||
"sudo",
|
||||
["vi", CONFIG_PATH],
|
||||
"vi",
|
||||
[CONFIG_PATH],
|
||||
{stdio: "inherit"}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var config = require("../../config");
|
||||
var ClientManager = new require("../clientManager");
|
||||
var program = require("commander");
|
||||
var shout = require("../server");
|
||||
var Helper = require("../helper");
|
||||
var config = Helper.getConfig();
|
||||
|
||||
program
|
||||
.option("-H, --host <ip>", "host")
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var Helper = module.exports = {
|
||||
getConfig: function () {
|
||||
return require(path.resolve(__dirname, "..", "config"));
|
||||
var filename = process.env.SHOUT_CONFIG;
|
||||
if(!filename || !fs.exists(filename)) {
|
||||
filename = this.resolveHomePath("config.js");
|
||||
if(!fs.exists(filename)) {
|
||||
filename = path.resolve(__dirname, "..", "config");
|
||||
}
|
||||
}
|
||||
return require(filename);
|
||||
},
|
||||
|
||||
getHomeDirectory: function () {
|
||||
return (
|
||||
this.getConfig().home
|
||||
(process.env.SHOUT_CONFIG && fs.exists(process.env.SHOUT_CONFIG) && this.getConfig().home)
|
||||
|| process.env.SHOUT_HOME
|
||||
|| path.resolve(process.env.HOME, ".shout")
|
||||
);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var config = require("../config");
|
||||
var fs = require("fs");
|
||||
var mkdirp = require("mkdirp");
|
||||
var moment = require("moment");
|
||||
var Helper = require("./helper");
|
||||
var config = Helper.getConfig();
|
||||
|
||||
module.exports = {
|
||||
write: function(user, network, chan, msg) {
|
||||
|
|
|
@ -2,11 +2,11 @@ var _ = require("lodash");
|
|||
var bcrypt = require("bcrypt");
|
||||
var Client = require("./client");
|
||||
var ClientManager = require("./clientManager");
|
||||
var config = require("../config");
|
||||
var express = require("express");
|
||||
var fs = require("fs");
|
||||
var io = require("socket.io");
|
||||
var Helper = require("./helper");
|
||||
var config = Helper.getConfig();
|
||||
|
||||
var sockets = null;
|
||||
var manager = new ClientManager();
|
||||
|
|
Loading…
Reference in a new issue