Add support for ~ home folder expansion
This commit is contained in:
parent
12c88debf4
commit
96d180077c
@ -1,10 +1,29 @@
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
var os = require("os");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
HOME: (process.env.HOME || process.env.USERPROFILE) + "/.lounge",
|
HOME: (process.env.HOME || process.env.USERPROFILE) + "/.lounge",
|
||||||
getConfig: getConfig
|
getConfig: getConfig,
|
||||||
|
expandHome: expandHome,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
return require(path.resolve(this.HOME) + "/config");
|
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 {
|
} else {
|
||||||
server = require("spdy");
|
server = require("spdy");
|
||||||
server = server.createServer({
|
server = server.createServer({
|
||||||
key: fs.readFileSync(https.key),
|
key: fs.readFileSync(Helper.expandHome(https.key)),
|
||||||
cert: fs.readFileSync(https.certificate)
|
cert: fs.readFileSync(Helper.expandHome(https.certificate))
|
||||||
}, app).listen(port, host);
|
}, app).listen(port, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user