-
Notifications
You must be signed in to change notification settings - Fork 0
/
try.js
44 lines (38 loc) · 986 Bytes
/
try.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
if( dir[dir.length-1] != '/')
dir=dir.concat('/')
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {
// build regex search
var re = new RegExp(/\entry.(json)/g);
if( re.test(file) ) {
console.log(file);
filelist.push(dir+file);
}
}
});
return filelist;
};
var getAppEntries=function(dir){
var files=walkSync(dir);
//var parsedJSON = require(x);
var mergeJSON = require("merge-json") ;
var result={};
files.forEach(function(file) {
var json= require(file);
//console.log(json)
result = mergeJSON.merge(result, json) ;
//console.log(result) ;
});
return result;
}
var x=getAppEntries(__dirname);
console.log(x.x)
console.log(12)