mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
save map config to local file
This commit is contained in:
18
lib/util.js
18
lib/util.js
@@ -21,9 +21,25 @@ module.exports.merge = function(baseObj, extendObj){
|
||||
return baseObj;
|
||||
}
|
||||
|
||||
module.exports.getUserHome = function(){
|
||||
function getUserHome(){
|
||||
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
||||
}
|
||||
module.exports.getUserHome = getUserHome;
|
||||
|
||||
|
||||
module.exports.getAnyProxyHome = function(){
|
||||
var home = path.join(util.getUserHome(),"/.anyproxy/");
|
||||
|
||||
if(!fs.existsSync(home)){
|
||||
try{
|
||||
fs.mkdirSync(home,0777);
|
||||
}catch(e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
module.exports.simpleRender = function(str, object, regexp){
|
||||
return String(str).replace(regexp || (/\{\{([^{}]+)\}\}/g), function(match, name){
|
||||
|
||||
Reference in New Issue
Block a user