Skip to content

Commit 0e79995

Browse files
committed
Sorted methods in utils file.
1 parent 193cac8 commit 0e79995

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

lib/utils.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
var fs = require('fs'),
22
path = require('path');
33

4-
module.exports.walk = function (dir, opts) {
5-
6-
var files = [];
7-
8-
if (!opts) {
9-
opts = {};
10-
}
11-
12-
if (!opts.match) {
13-
opts.match = /\.js$/;
14-
}
15-
16-
if (!opts.exception) {
17-
opts.exception = /\.git|\.min|node_modules|test|gruntfile/i;
18-
}
19-
20-
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
21-
22-
fs.readdirSync(dir).forEach(function (file) {
23-
24-
var stat;
25-
26-
file = path.normalize(dir + '/' + file);
27-
28-
stat = fs.statSync(file);
29-
30-
if (stat.isDirectory() && !file.match(opts.exception)) {
31-
32-
files = files.concat(module.exports.walk(file, opts));
33-
34-
} else if (stat.isFile() && file.match(opts.match) && !file.match(opts.exception)) {
35-
36-
files.push(file);
37-
38-
}
39-
40-
});
41-
42-
}
43-
44-
return files;
45-
46-
};
47-
484
module.exports.formatStringForUID = function (content) {
495

506
content = String(content).toLowerCase();
@@ -94,3 +50,47 @@ module.exports.parseData = function (data, file) {
9450
return data;
9551

9652
};
53+
54+
module.exports.walk = function (dir, opts) {
55+
56+
var files = [];
57+
58+
if (!opts) {
59+
opts = {};
60+
}
61+
62+
if (!opts.match) {
63+
opts.match = /\.js$/;
64+
}
65+
66+
if (!opts.exception) {
67+
opts.exception = /\.git|\.min|node_modules|test|gruntfile/i;
68+
}
69+
70+
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
71+
72+
fs.readdirSync(dir).forEach(function (file) {
73+
74+
var stat;
75+
76+
file = path.normalize(dir + '/' + file);
77+
78+
stat = fs.statSync(file);
79+
80+
if (stat.isDirectory() && !file.match(opts.exception)) {
81+
82+
files = files.concat(module.exports.walk(file, opts));
83+
84+
} else if (stat.isFile() && file.match(opts.match) && !file.match(opts.exception)) {
85+
86+
files.push(file);
87+
88+
}
89+
90+
});
91+
92+
}
93+
94+
return files;
95+
96+
};

0 commit comments

Comments
 (0)