mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 20:43:08 +00:00
Merge pull request #284 from maxpoulin64/tilde
Add support for ~ home folder expansion
This commit is contained in:
commit
8380fc3b68
2 changed files with 22 additions and 3 deletions
|
@ -1,10 +1,29 @@
|
|||
var path = require("path");
|
||||
var os = require("os");
|
||||
|
||||
module.exports = {
|
||||
HOME: (process.env.HOME || process.env.USERPROFILE) + "/.lounge",
|
||||
getConfig: getConfig
|
||||
getConfig: getConfig,
|
||||
expandHome: expandHome,
|
||||
};
|
||||
|
||||
function getConfig() {
|
||||
return require(path.resolve(this.HOME) + "/config");
|
||||
}
|
||||
|
||||
function expandHome(path) {
|
||||
var home;
|
||||
|
||||
if (os.homedir) {
|
||||
home = os.homedir();
|
||||
}
|
||||
|
||||
if (!home) {
|
||||
home = process.env.HOME || "";
|
||||
}
|
||||
|
||||
home = home.replace("$", "$$$$");
|
||||
|
||||
return path.replace(/^~($|\/|\\)/, home + "$1");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ module.exports = function(options) {
|
|||
} else {
|
||||
server = require("spdy");
|
||||
server = server.createServer({
|
||||
key: fs.readFileSync(https.key),
|
||||
cert: fs.readFileSync(https.certificate)
|
||||
key: fs.readFileSync(Helper.expandHome(https.key)),
|
||||
cert: fs.readFileSync(Helper.expandHome(https.certificate))
|
||||
}, app).listen(port, host);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue