-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
57 lines (50 loc) · 1.35 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
//Dependencies
const Path = require("path")
const Fs = require("fs")
//Variables
const Self_Args = process.argv.slice(2)
//Functions
function walk(dir, done) { //Not mine :)
var results = [];
Fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file) {
file = Path.resolve(dir, file);
Fs.stat(file, function(err, stat) {
if (stat && stat.isDirectory()) {
walk(file, function(err, res) {
results = results.concat(res);
if (!--pending) done(null, results);
});
} else {
results.push(file);
if (!--pending) done(null, results);
}
});
});
});
};
//Main
if(!Self_Args.length){
console.log(`node index.js <directory>
Example: node index.js ./test_directory`)
process.exit()
}
if(!Self_Args[0]){
console.log("Invalid directory.")
process.exit()
}
walk(Self_Args[0], function(err, files){
for( i in files ){
if(files[i] != ""){
const data = Fs.readFileSync(files[i], "utf8")
if(data.indexOf("SQLite format") != -1){
console.log(`${files[i]} is a SQLite database.`)
}
}
}
console.log("Done.")
process.exit()
})