mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
reconstruct map local
This commit is contained in:
37
lib/util.js
37
lib/util.js
@@ -1,3 +1,6 @@
|
||||
var fs = require("fs"),
|
||||
path = require("path");
|
||||
|
||||
// {"Content-Encoding":"gzip"} --> {"content-encoding":"gzip"}
|
||||
module.exports.lower_keys = function(obj){
|
||||
for(var key in obj){
|
||||
@@ -27,5 +30,37 @@ module.exports.simpleRender = function(str, object, regexp){
|
||||
if (match.charAt(0) == '\\') return match.slice(1);
|
||||
return (object[name] != null) ? object[name] : '';
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports.filewalker = function(root,cb){
|
||||
root = root || process.cwd();
|
||||
|
||||
var ret = {
|
||||
directory :[],
|
||||
file :[]
|
||||
};
|
||||
|
||||
fs.readdir(root,function(err, list){
|
||||
if(list && list.length){
|
||||
list.map(function(item){
|
||||
var fullPath = path.join(root,item),
|
||||
stat = fs.lstatSync(fullPath);
|
||||
|
||||
if(stat.isFile()){
|
||||
ret.file.push({
|
||||
name : item,
|
||||
fullPath : fullPath
|
||||
});
|
||||
|
||||
}else if(stat.isDirectory()){
|
||||
ret.directory.push({
|
||||
name : item,
|
||||
fullPath : fullPath
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cb && cb.apply(null,[null,ret]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user