thelounge/src/helper.js

30 lines
497 B
JavaScript
Raw Normal View History

2014-10-04 23:22:23 +00:00
var path = require("path");
var os = require("os");
2014-10-04 23:22:23 +00:00
2014-10-03 23:33:44 +00:00
module.exports = {
HOME: (process.env.HOME || process.env.USERPROFILE) + "/.lounge",
getConfig: getConfig,
expandHome: expandHome,
};
2014-10-03 23:33:44 +00:00
function getConfig() {
2014-10-04 23:22:23 +00:00
return require(path.resolve(this.HOME) + "/config");
2015-09-30 22:39:57 +00:00
}
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");
}